| Index: utils/pub/io.dart
|
| diff --git a/utils/pub/io.dart b/utils/pub/io.dart
|
| index 7a6357080490b5d08a57f8b03bea855fa020c1ef..ac9836af5078e2e40ed4f6496376f3bc5fd31e5d 100644
|
| --- a/utils/pub/io.dart
|
| +++ b/utils/pub/io.dart
|
| @@ -258,9 +258,13 @@ String getFullPath(entry) => new File(_getPath(entry)).fullPathSync();
|
| * Spawns and runs the process located at [executable], passing in [args].
|
| * Returns a [Future] that will complete the results of the process after it
|
| * has ended.
|
| + *
|
| + * If [pipeStdout] and/or [pipeStderr] are set, all output from the subprocess's
|
| + * output streams are sent to the parent process's output streams. Output from
|
| + * piped streams won't be available in the result object.
|
| */
|
| Future<PubProcessResult> runProcess(String executable, List<String> args,
|
| - [String workingDir]) {
|
| + [String workingDir, bool pipeStdout = false, bool pipeStderr = false]) {
|
| int exitCode;
|
|
|
| final options = new ProcessOptions();
|
| @@ -278,21 +282,29 @@ Future<PubProcessResult> runProcess(String executable, List<String> args,
|
|
|
| checkComplete() {
|
| // Wait until the process is done and its output streams are closed.
|
| - if (!outStream.closed) return;
|
| - if (!errStream.closed) return;
|
| + if (!pipeStdout && !outStream.closed) return;
|
| + if (!pipeStderr && !errStream.closed) return;
|
| if (exitCode == null) return;
|
|
|
| completer.complete(new PubProcessResult(
|
| processStdout, processStderr, exitCode));
|
| }
|
|
|
| - outStream.onLine = () => processStdout.add(outStream.readLine());
|
| - outStream.onClosed = checkComplete;
|
| - outStream.onError = (error) => completer.completeException(error);
|
| + if (pipeStdout) {
|
| + process.stdout.pipe(stdout, close: false);
|
| + } else {
|
| + outStream.onLine = () => processStdout.add(outStream.readLine());
|
| + outStream.onClosed = checkComplete;
|
| + outStream.onError = (error) => completer.completeException(error);
|
| + }
|
|
|
| - errStream.onLine = () => processStderr.add(errStream.readLine());
|
| - errStream.onClosed = checkComplete;
|
| - errStream.onError = (error) => completer.completeException(error);
|
| + if (pipeStderr) {
|
| + process.stderr.pipe(stderr, close: false);
|
| + } else {
|
| + errStream.onLine = () => processStderr.add(errStream.readLine());
|
| + errStream.onClosed = checkComplete;
|
| + errStream.onError = (error) => completer.completeException(error);
|
| + }
|
|
|
| process.onExit = (actualExitCode) {
|
| exitCode = actualExitCode;
|
| @@ -313,6 +325,8 @@ class PubProcessResult {
|
| final int exitCode;
|
|
|
| const PubProcessResult(this.stdout, this.stderr, this.exitCode);
|
| +
|
| + bool get success() => exitCode == 0;
|
| }
|
|
|
| /**
|
|
|