recursivePubPath function
Future<List<String> >
recursivePubPath(
- List<
String> dirs, { - List<
String> ? dependencies, - FilterDartProjectOptions? filterDartProjectOptions,
if forceRecursive
is true, we folder going deeper even if the current
path is a dart project
if ignoreSdkConstraints
is true, it lists the project even if not compatible.
Returns the list of valid pub folder, including me
Implementation
Future<List<String>> recursivePubPath(List<String> dirs,
{List<String>? dependencies,
FilterDartProjectOptions? filterDartProjectOptions}) async {
var pubDirs = await filterPubPath(dirs,
dependencies: dependencies,
filterDartProjectOptions: filterDartProjectOptions);
Future<List<String>> getSubDirs(String dir) async {
if (!_isToBeIgnored(basename(dir))) {
// devPrint('testing: $dir');
final sub = <String>[];
final futures = <Future>[];
await Directory(dir).list().listen((FileSystemEntity fse) {
var subDir = fse.path;
// Make sure it is not added even if it is a package root
if (!_isToBeIgnored(basename(subDir))) {
if (isDirectoryNotLinkSynk(subDir)) {
futures.add(() async {
if (await isPubPackageRoot(subDir,
filterDartProjectOptions: filterDartProjectOptions)) {
sub.add(subDir);
}
sub.addAll(await getSubDirs(subDir));
}());
}
}
}).asFuture<void>();
await Future.wait(futures);
return sub;
}
return <String>[];
}
for (final dir in dirs) {
if (isDirectoryNotLinkSynk(dir)) {
pubDirs.addAll(await getSubDirs(dir));
} else {
throw '$dir not a directory';
}
}
return removeDuplicates(pubDirs)..sort();
}