findAllPackages function

List<DartPackage> findAllPackages(
  1. Directory directory
)

Returns the list of all packages in the repository

Implementation

List<DartPackage> findAllPackages(Directory directory) {
  return directory
      .allSubDirectories((dir) {
        if (dir.name.startsWith('.')) {
          // ignore hidden folders
          return false;
        }
        if (dir.name == 'build') {
          // keep folders named 'build' unless they are in the root of a
          // DartPackage (which means they've been generated by that package)
          final package = DartPackage.fromDirectory(dir.parent);
          if (package != null) {
            // ignore <dartPackage>/build dir
            return false;
          }
        }
        return true;
      })
      .mapNotNull((it) => DartPackage.fromDirectory(it))
      .toList();
}