runAsyncProcess function

Future<Process> runAsyncProcess(
  1. String executable,
  2. List<String> arguments, {
  3. String? workingDirectory,
  4. Map<String, String>? environment,
  5. bool includeParentEnvironment = true,
  6. bool runInShell = false,
  7. bool printCall = false,
})

Implementation

Future<Process> runAsyncProcess(
  String executable,
  List<String> arguments, {
  String? workingDirectory,
  Map<String, String>? environment,
  bool includeParentEnvironment = true,
  bool runInShell = false,
  bool printCall = false,
}) async {
  if (printCall) {
    print('$executable ${arguments.join(' ')}');
  }
  final result = await Process.start(
    executable,
    arguments,
    workingDirectory: workingDirectory,
    environment: environment,
    includeParentEnvironment: includeParentEnvironment,
    runInShell: runInShell,
  );
  stdout.addStream(result.stdout);
  stderr.addStream(result.stderr);
  if (await result.exitCode != 0) {
    throw Exception('Process "$executable" failed. See log above.');
  }
  return result;
}