all method

  1. @override
Future<Iterable<String>> all({
  1. bool recursive = false,
})
override

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;
}