runSequence static method

Future<void> runSequence(
  1. void runner(
    1. String path
    )
)

Implementation

static Future<void> runSequence(void Function(String path) runner) async {
  final workingDirectoryFlutter = find('pubspec.yaml', workingDirectory: '.')
      .toList()
      .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 {
        print('🚀 $path');
        runner.call(path);
        print('✅  $path');
      } catch (e) {
        print('❌  $path');
        rethrow;
      }
    });
  }

  final length = futures.length;
  print('📦 Total Packages: $length');
  print('---------------------------------------');
  for (var element in futures) {
    await element.call();
  }
}