runSequence static method
Future<void>
runSequence(
- void runner(
- String path
), {
- bool ignorePubWorkspaces = false,
})
Implementation
static Future<void> runSequence(
void Function(String path) runner, {
bool ignorePubWorkspaces = false,
}) async {
final workingDirectoryFlutter = find('pubspec.yaml', workingDirectory: '.')
.toList()
.where(
(element) {
if (ignorePubWorkspaces) {
return true;
}
final resolution = 'resolution';
final yaml = YamlHelper.loadFileYaml(element);
final hasResolution = yaml.containsKey(resolution);
return !hasResolution;
},
)
.map((e) => e.replaceAll('${separator}pubspec.yaml', ''))
.sorted((a, b) =>
b.split(separator).length.compareTo(a.split(separator).length));
List<Future Function()> futures = [];
for (var e in workingDirectoryFlutter) {
futures.add(() async {
final path = e.replaceAll(current, '.');
try {
printMessage('π $path');
runner.call(path);
printMessage('β
$path');
} catch (e) {
printMessage('β $path');
rethrow;
}
});
}
final length = futures.length;
printMessage('π¦ Total Packages: $length');
printMessage('---------------------------------------');
for (var element in futures) {
await element.call();
}
}