runSync method

  1. @override
ProcessResult runSync(
  1. List<Object> command,
  2. {String? workingDirectory,
  3. Map<String, String>? environment,
  4. bool includeParentEnvironment = true,
  5. bool runInShell = false,
  6. Encoding? stdoutEncoding = systemEncoding,
  7. Encoding? stderrEncoding = systemEncoding}
)
override

Starts a process and runs it to completion. This is a synchronous call and will block until the child process terminates.

The arguments are the same as for run`.

Returns a ProcessResult with the result of running the process, i.e., exit code, standard out and standard in.

Implementation

@override
ProcessResult runSync(
  List<Object> command, {
  String? workingDirectory,
  Map<String, String>? environment,
  bool includeParentEnvironment = true,
  bool runInShell = false,
  Encoding? stdoutEncoding = systemEncoding,
  Encoding? stderrEncoding = systemEncoding,
}) {
  try {
    return Process.runSync(
      sanitizeExecutablePath(_getExecutable(
        command,
        workingDirectory,
        runInShell,
      )),
      _getArguments(command),
      workingDirectory: workingDirectory,
      environment: environment,
      includeParentEnvironment: includeParentEnvironment,
      runInShell: runInShell,
      stdoutEncoding: stdoutEncoding,
      stderrEncoding: stderrEncoding,
    );
  } on ProcessException catch (exception) {
    throw ProcessPackageException.fromProcessException(exception,
        workingDirectory: workingDirectory);
  }
}