Chromium Code Reviews| Index: utils/pub/io.dart |
| diff --git a/utils/pub/io.dart b/utils/pub/io.dart |
| index c2f14568906fd92033c75fdd9e71d1b2c4990d43..13de28191687c4a2eb180b05de6a09d771336c05 100644 |
| --- a/utils/pub/io.dart |
| +++ b/utils/pub/io.dart |
| @@ -471,15 +471,17 @@ Future<List<int>> consumeInputStream(InputStream stream) { |
| return completer.future; |
| } |
| -/** |
| - * 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. |
| - */ |
| +/// 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. |
| +/// |
| +/// The spawned process will inherit its parents environment variables. If |
|
nweiz
2012/10/30 23:29:59
"parents" -> "parent's"
Bob Nystrom
2012/10/30 23:31:42
Done.
|
| +/// [environment] is provided, that will be used to augment (not replace) the |
| +/// the inherited variables. |
| +/// |
| +/// 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, |
| {workingDir, Map<String, String> environment, bool pipeStdout: false, |
| bool pipeStderr: false}) { |
| @@ -499,7 +501,11 @@ Future<PubProcessResult> runProcess(String executable, List<String> args, |
| if (workingDir != null) { |
| options.workingDirectory = _getDirectory(workingDir).path; |
| } |
| - options.environment = environment; |
| + |
| + if (environment != null) { |
| + options.environment = new Map.from(Platform.environment); |
| + environment.forEach((key, value) => options.environment[key] = value); |
| + } |
| var future = Process.run(executable, args, options); |
| return future.transform((result) { |
| @@ -556,8 +562,11 @@ Future<bool> get isGitInstalled { |
| } |
| /// Run a git process with [args] from [workingDir]. |
| -Future<PubProcessResult> runGit(List<String> args, {String workingDir}) => |
| - _gitCommand.chain((git) => runProcess(git, args, workingDir: workingDir)); |
| +Future<PubProcessResult> runGit(List<String> args, |
| + {String workingDir, Map<String, String> environment}) { |
| + return _gitCommand.chain((git) => runProcess(git, args, |
| + workingDir: workingDir, environment: environment)); |
| +} |
| /// Returns the name of the git command-line app, or null if Git could not be |
| /// found on the user's PATH. |