run method
Runs this command.
The return value is wrapped in a Future if necessary and returned by
CommandRunner.runCommand.
Implementation
@override
Future<int> run() async {
final words = argResults!.rest;
if (words.isEmpty) {
usageException('Give the command to run.');
}
final command = words.length == 1
? words.single
: withArguments(words.first, words.sublist(1));
final selection = packageSelection(argResults!);
final project = context.requireProject;
final RunPlan plan;
try {
plan = planRun(
workspace: project.workspace,
filters: selection.filters,
allPackagesByDefault: true,
concurrency: selection.concurrency,
failFast: selection.failFast ?? false,
dependencyOrder: selection.dependencyOrder ?? false,
);
} on RunPlanException catch (e) {
throw DpkException(e.message);
}
return withTerminalTitle(
console,
'dpk exec',
() => context.withHooks('exec', (stack) {
console.step(
'> exec in ${plan.packages.length} '
'package${plan.packages.length == 1 ? '' : 's'}: $command',
);
return ScriptExecutor(
processRunner: context.processRunner,
console: console,
workspace: project.workspace,
).execute(
plan,
command,
environment: context.scriptEnvironment({
...project.pubEnvironment,
...stack.toEnvironment(),
}),
);
}),
);
}