run method

  1. @override
Future<int> run([
  1. List<String>? args
])
override

Runs this command.

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

Implementation

@override
Future<int> run([List<String>? args]) async {
  final argResults = args != null ? argParser.parse(args) : this.argResults;
  final providedConfigPath = argResults?['config'] as String?;

  final handler = BuildHandler(
    logger: logger,
    fs: fs,
    settings: settings,
    providedConfigPath: providedConfigPath,
    exitOnChange: false,
    keyPressListener: keyPressListener,
  );

  await handler.run();

  while (true) {
    final (exit: exit) = await handler.waitForChange();

    if (exit) {
      break;
    }

    await handler.run();
  }

  return 0;
}