getBarrels method
Implementation
Future<List<Barrel>> getBarrels(Settings settings) async {
final barrels = <Barrel>[];
for (final dir in settings.dirs) {
final matches =
await Glob(dir.dirPath).listFileSystemSync(fs, followLinks: false);
if (matches.length == 1) {
barrels.add(Barrel.from(settings, dir, fs, logger));
continue;
}
for (final entity in matches) {
if (entity is! Directory) {
continue;
}
final updated =
dir.changePath(entity.path.relativeTo(fs.currentDirectory.path));
barrels.add(Barrel.from(settings, updated, fs, logger));
}
}
// longest path first, incase nested directories barrel files are to be exported later
barrels.sort((a, b) =>
b.dirSettings.dirPath.length.compareTo(a.dirSettings.dirPath.length));
return barrels;
}