run method

  1. @override
Future<ExitCode> run()
override

Runs this command.

The return value is wrapped in a Future if necessary and returned by CommandRunner.runCommand.

Implementation

@override
Future<ExitCode> run() async {
  final pubspecs = await pubspecYaml.all(recursive: true);

  if (pubspecs.isEmpty) {
    logger.err('No pubspec.yaml files found');
    return ExitCode.unavailable;
  }

  final testDirsResult = getTestDirs(
    pubspecs,
    isFlutterOnly: false,
    isDartOnly: false,
  );

  // exit code is not null
  if (testDirsResult.$2 case final ExitCode exitCode) {
    return exitCode;
  }
  final (testDirs, _) = testDirsResult.$1!;

  final optimized = <String>[];
  for (final dir in testDirs) {
    final file = findFile.fileWithin(TesterMixin.optimizedTestBasename, dir);

    if (file == null) continue;

    optimized.add(file);
  }

  final done = logger.progress('Cleaning up optimized test files');

  cleanUpOptimizedFiles(optimized);

  done.complete('Optimized test files cleaned!');

  return ExitCode.success;
}