run function
Synchronously run an executable.
If quiet is false, logs the stdout. The stderr is always logged.
Returns the stdout.
All other optional parameters are forwarded to Process.runSync.
Implementation
String run(String executable,
{List<String> arguments: const [],
RunOptions runOptions,
bool quiet: false,
String workingDirectory}) {
runOptions = mergeWorkingDirectory(workingDirectory, runOptions);
if (!quiet) log("${executable} ${arguments.join(' ')}");
if (runOptions == null) runOptions = new RunOptions();
ProcessResult result = Process.runSync(executable, arguments,
workingDirectory: runOptions.workingDirectory,
environment: runOptions.environment,
includeParentEnvironment: runOptions.includeParentEnvironment,
runInShell: runOptions.runInShell,
stdoutEncoding: runOptions.stdoutEncoding,
stderrEncoding: runOptions.stderrEncoding);
if (!quiet) {
if (result.stdout != null && result.stdout.isNotEmpty) {
log(result.stdout.trim());
}
}
if (result.stderr != null && result.stderr.isNotEmpty) {
log(result.stderr);
}
if (result.exitCode != 0) {
throw new ProcessException._(
executable, result.exitCode, result.stdout, result.stderr);
}
return result.stdout;
}