run method

Future<int> run({
  1. bool skipIfMissing = false,
})

Implementation

Future<int> run({
  /// If true, the script will be skipped if it is not found in the config.
  bool skipIfMissing = false,
}) async {
  assert(options.script != null, 'Script name is required');

  IntCallback? preHook;
  IntCallback? postHook;

  if (config.scripts?.scriptsMap.containsKey(options.script) == true) {
    (preHook, postHook) = _getHooks(
      config: config,
      options: options,
      arguments: arguments,
    );
  }

  final preHookExitCode = await preHook?.call();
  if (preHookExitCode != null && preHookExitCode != 0) {
    return preHookExitCode;
  }

  final exitCode = await _runScript(
    config: config,
    options: options,
    arguments: arguments,
    skipIfMissing: skipIfMissing,
  );
  if (exitCode != 0) {
    return exitCode;
  }

  final postHookExitCode = await postHook?.call();
  return postHookExitCode ?? 0;
}