runStreaming function

Future<int> runStreaming(
  1. String executable,
  2. List<String> args, {
  3. String? workingDirectory,
})

Runs executable and streams its stdout/stderr to the terminal in real time. Returns the exit code.

Implementation

Future<int> runStreaming(String executable, List<String> args, {String? workingDirectory}) async {
  final process = await Process.start(executable, args, workingDirectory: workingDirectory);
  await Future.wait([
    process.stdout.pipe(stdout),
    process.stderr.pipe(stderr),
  ]);
  return process.exitCode;
}