run method

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

Runs this command.

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

Implementation

@override
Future<bool> run() async {
  final runner = super.runner!;
  final dockerSeq = [
    'check',
    'validate',
    'shared',
    'docker',
    'aggregate',
    'deps',
  ];
  final buildSeq = ['check', 'lambda'];
  final execSeq = (Utils.isInDocker ? buildSeq : dockerSeq);

  final baseArgs = (argResults?.arguments ?? []).where((a) => a != name);
  for (var step in execSeq) {
    final cmd = runner.commands[step];
    if (cmd == null) throw Exception('A sequenced command is missing! 🪲');

    final cmdArgs = baseArgs.where((argName) =>
        cmd.argParser
            .findByNameOrAlias(argName.replaceAll(RegExp('-'), '')) !=
        null);
    final args = [cmd.name, ...cmdArgs];
    final result = (await runner.run(args)) ?? false;
    if (!result) throw Exception('Step Failed: $step 😢');
  }

  return true;
}