all method
This method is used to find all the pubspecs in the project
When recursive
is true, this finds pubspecs in subdirectories
as well as the current directory.
When recursive
is false, this only finds the pubspec in the
current directory.
Implementation
@override
Future<Iterable<String>> all({bool recursive = false}) async {
final pubspecs = <String>{};
final pubspec = nearest();
if (pubspec != null) {
pubspecs.add(pubspec);
}
if (recursive) {
final children = await this.children();
pubspecs.addAll(children.map((e) => path.join(path.separator, e)));
}
final sortedPubspecs = [...pubspecs]
..sort()
..sort((a, b) => path.split(b).length - path.split(a).length);
return sortedPubspecs
..removeWhere((e) {
// if within a build directory, ignore
if (e.contains('${path.separator}build${path.separator}')) {
return true;
}
// if within a .dart_tool directory, ignore
if (e.contains('${path.separator}.dart_tool${path.separator}')) {
return true;
}
return false;
});
}