run method
Future<void>
run({
- GlobalOptions? global,
- String? scriptName,
- bool noSelect = false,
- List<
String> extraArgs = const [],
inherited
Implementation
@override
Future<void> run({
GlobalOptions? global,
String? scriptName,
bool noSelect = false,
List<String> extraArgs = const [],
}) async {
if (config.scripts.keys.isEmpty) throw NoScriptException._();
scriptName ??= await _pickScript(config);
final script = config.scripts[scriptName];
if (script == null) {
throw ScriptNotFoundException._(
scriptName,
config.scripts.keys.toList(),
);
}
if (script.steps != null && script.steps!.isNotEmpty) {
if (script.exec != null) {
throw ScriptExecOptionsException._(
scriptName,
);
}
_detectRecursiveScriptCalls(script);
await _runMultipleScripts(
script,
global: global,
noSelect: noSelect,
scripts: config.scripts,
steps: script.steps!,
);
return;
}
if (script.run == null && script.exec is! String) {
throw MissingScriptCommandException._(
scriptName,
);
}
final scriptSourceCode = targetStyle(
script.command(extraArgs).join(' ').withoutTrailing('\n'),
);
logger.command('melos run ${script.name}');
logger.child(scriptSourceCode).child(runningLabel).newLine();
final exitCode = await _runScript(
script,
global: global,
noSelect: noSelect,
extraArgs: extraArgs,
);
logger.newLine();
logger.command('melos run ${script.name}');
final resultLogger = logger.child(scriptSourceCode);
if (exitCode != 0) {
resultLogger.child(failedLabel);
throw ScriptException._(script.name);
}
resultLogger.child(successLabel);
}