| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Helper functionality to make working with IO easier. | 6 * Helper functionality to make working with IO easier. |
| 7 */ | 7 */ |
| 8 #library('io'); | 8 #library('io'); |
| 9 | 9 |
| 10 #import('dart:io'); | 10 #import('dart:io'); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 /** | 326 /** |
| 327 * Spawns and runs the process located at [executable], passing in [args]. | 327 * Spawns and runs the process located at [executable], passing in [args]. |
| 328 * Returns a [Future] that will complete the results of the process after it | 328 * Returns a [Future] that will complete the results of the process after it |
| 329 * has ended. | 329 * has ended. |
| 330 * | 330 * |
| 331 * If [pipeStdout] and/or [pipeStderr] are set, all output from the subprocess's | 331 * If [pipeStdout] and/or [pipeStderr] are set, all output from the subprocess's |
| 332 * output streams are sent to the parent process's output streams. Output from | 332 * output streams are sent to the parent process's output streams. Output from |
| 333 * piped streams won't be available in the result object. | 333 * piped streams won't be available in the result object. |
| 334 */ | 334 */ |
| 335 Future<PubProcessResult> runProcess(String executable, List<String> args, | 335 Future<PubProcessResult> runProcess(String executable, List<String> args, |
| 336 [workingDir, bool pipeStdout = false, bool pipeStderr = false]) { | 336 [workingDir, Map<String, String> environment, bool pipeStdout = false, |
| 337 bool pipeStderr = false]) { |
| 337 int exitCode; | 338 int exitCode; |
| 338 | 339 |
| 339 final options = new ProcessOptions(); | 340 final options = new ProcessOptions(); |
| 340 if (workingDir != null) { | 341 if (workingDir != null) { |
| 341 options.workingDirectory = _getDirectory(workingDir).path; | 342 options.workingDirectory = _getDirectory(workingDir).path; |
| 342 } | 343 } |
| 344 options.environment = environment; |
| 343 | 345 |
| 344 final process = Process.start(executable, args, options); | 346 final process = Process.start(executable, args, options); |
| 345 | 347 |
| 346 final outStream = new StringInputStream(process.stdout); | 348 final outStream = new StringInputStream(process.stdout); |
| 347 final processStdout = <String>[]; | 349 final processStdout = <String>[]; |
| 348 | 350 |
| 349 final errStream = new StringInputStream(process.stderr); | 351 final errStream = new StringInputStream(process.stderr); |
| 350 final processStderr = <String>[]; | 352 final processStderr = <String>[]; |
| 351 | 353 |
| 352 final completer = new Completer<PubProcessResult>(); | 354 final completer = new Completer<PubProcessResult>(); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 return new Directory(entry); | 471 return new Directory(entry); |
| 470 } | 472 } |
| 471 | 473 |
| 472 /** | 474 /** |
| 473 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. | 475 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. |
| 474 */ | 476 */ |
| 475 Uri _getUri(uri) { | 477 Uri _getUri(uri) { |
| 476 if (uri is Uri) return uri; | 478 if (uri is Uri) return uri; |
| 477 return new Uri.fromString(uri); | 479 return new Uri.fromString(uri); |
| 478 } | 480 } |
| OLD | NEW |