run method
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');
final scriptExists =
config.scripts?.scriptsMap.containsKey(options.script) == true;
if (!scriptExists && skipIfMissing) {
return 0;
}
final targetDirectory =
options.globalOptions.directory ?? config.workingDirectory;
Directory.current = targetDirectory;
IntCallback? preHook;
IntCallback? postHook;
if (scriptExists) {
(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;
}