pubspecs method
Implementation
@override
Future<Iterable<String>> pubspecs({required bool recursive}) async {
final packages = {...?argResults?.rest};
final pubspecs = await super.pubspecs(recursive: recursive);
if (packages.isEmpty) {
return pubspecs;
}
final files = pubspecs.map(File.new);
// read the pubspec.yaml file
final pubspecYamls = await Future.wait(files.map((e) => e.readAsString()));
Iterable<String> pubspecsWithDependencies() sync* {
for (final (index, content) in pubspecYamls.indexed) {
final yaml = loadYaml(content) as YamlMap;
final dependencies = {
...?yaml['dependencies'] as YamlMap?,
...?yaml['dev_dependencies'] as YamlMap?,
};
final dependencyKeys = dependencies.keys.cast<String>().toSet();
if (packages.intersection(dependencyKeys).isNotEmpty) {
yield pubspecs.elementAt(index);
}
}
}
return pubspecsWithDependencies();
}