runLiveShellCommand function
Runs the metro live command name with arguments on runner's
session and returns its exit code.
name is a live command without its prefix (status, seed), a
live:run action (route), or one of the project's live commands
(app:seed_demo, or seed_demo when only one command has that name).
Returns null when nothing has that name.
Implementation
Future<int?> runLiveShellCommand(
String name,
List<String> arguments,
LiveRunner runner,
) async {
String command = name.startsWith('live:') ? name.substring(5) : name;
List<String> rest = arguments;
if (command == 'run') {
if (arguments.isEmpty) return null;
command = arguments.first;
rest = arguments.sublist(1);
}
final NyCustomCommand Function(List<String>)? create =
_liveShellBuiltIns[command] ?? liveRunActions[command]?.create;
if (create != null) {
return (create(rest) as _LiveBuiltInCommand).runWith(runner);
}
final String? moved = liveCommandMoved(command, runner: runner);
if (moved != null) {
runner.output.error(moved);
return 64;
}
final String? appCommand = resolveLiveAppCommand(
command,
LiveManifest.load(),
);
if (appCommand == null) return null;
return runLiveCustomCommand(appCommand, rest, runner: runner);
}