runProcess static method

Future<int> runProcess(
  1. String command
)

Runs a process

Implementation

static Future<int> runProcess(String command) async {
  List<String> commands = command.split(" ");

  final processArguments = commands.getRange(1, commands.length).toList();

  final process =
      await Process.start(commands.first, processArguments, runInShell: true);

  // Connect all streams
  process.stdout.pipe(stdout);
  process.stderr.pipe(stderr);
  stdin.pipe(process.stdin); // This pipes stdin to the child process

  final exitCode = await process.exitCode;

  if (exitCode != 0) {
    MetroConsole.writeInRed("Error: $exitCode");
  }

  return exitCode;
}