Chromium Code Reviews| Index: utils/pub/io.dart |
| diff --git a/utils/pub/io.dart b/utils/pub/io.dart |
| index e6c79ca853701c5e85fef70008b5c24ef73d3ff2..00defd188efdb4805d8c670dce7351d33a23d82a 100644 |
| --- a/utils/pub/io.dart |
| +++ b/utils/pub/io.dart |
| @@ -320,9 +320,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 stream(s) to the parent process's output stream(s). Output from piped |
|
Bob Nystrom
2012/05/08 17:01:49
"to the" -> "are sent to the".
Also "(s)" -> "s".
nweiz
2012/05/09 00:21:04
Done.
|
| + * streams won't be available in the result object. |
| */ |
| Future<ProcessResult> runProcess(String executable, List<String> args, |
| - [String workingDir]) { |
| + [String workingDir, bool pipeStdout = false, bool pipeStderr = false]) { |
| int exitCode; |
| final options = new ProcessOptions(); |
| @@ -348,13 +352,21 @@ Future<ProcessResult> runProcess(String executable, List<String> args, |
| 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; |
| @@ -375,6 +387,8 @@ class ProcessResult { |
| final int exitCode; |
| const ProcessResult(this.stdout, this.stderr, this.exitCode); |
| + |
| + bool get success() => exitCode == 0; |
| } |
| /** |