| 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('pub_io'); | 8 #library('pub_io'); |
| 9 | 9 |
| 10 #import('dart:io'); | 10 #import('dart:io'); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 /** | 257 /** |
| 258 * Spawns and runs the process located at [executable], passing in [args]. | 258 * Spawns and runs the process located at [executable], passing in [args]. |
| 259 * Returns a [Future] that will complete the results of the process after it | 259 * Returns a [Future] that will complete the results of the process after it |
| 260 * has ended. | 260 * has ended. |
| 261 * | 261 * |
| 262 * If [pipeStdout] and/or [pipeStderr] are set, all output from the subprocess's | 262 * If [pipeStdout] and/or [pipeStderr] are set, all output from the subprocess's |
| 263 * output streams are sent to the parent process's output streams. Output from | 263 * output streams are sent to the parent process's output streams. Output from |
| 264 * piped streams won't be available in the result object. | 264 * piped streams won't be available in the result object. |
| 265 */ | 265 */ |
| 266 Future<PubProcessResult> runProcess(String executable, List<String> args, | 266 Future<PubProcessResult> runProcess(String executable, List<String> args, |
| 267 [String workingDir, bool pipeStdout = false, bool pipeStderr = false]) { | 267 [workingDir, bool pipeStdout = false, bool pipeStderr = false]) { |
| 268 int exitCode; | 268 int exitCode; |
| 269 | 269 |
| 270 final options = new ProcessOptions(); | 270 final options = new ProcessOptions(); |
| 271 if (workingDir != null) options.workingDirectory = workingDir; | 271 if (workingDir != null) { |
| 272 options.workingDirectory = _getDirectory(workingDir).path; |
| 273 } |
| 272 | 274 |
| 273 final process = Process.start(executable, args, options); | 275 final process = Process.start(executable, args, options); |
| 274 | 276 |
| 275 final outStream = new StringInputStream(process.stdout); | 277 final outStream = new StringInputStream(process.stdout); |
| 276 final processStdout = <String>[]; | 278 final processStdout = <String>[]; |
| 277 | 279 |
| 278 final errStream = new StringInputStream(process.stderr); | 280 final errStream = new StringInputStream(process.stderr); |
| 279 final processStderr = <String>[]; | 281 final processStderr = <String>[]; |
| 280 | 282 |
| 281 final completer = new Completer<PubProcessResult>(); | 283 final completer = new Completer<PubProcessResult>(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 } | 344 } |
| 343 | 345 |
| 344 /** | 346 /** |
| 345 * Gets a [Directory] for [entry], which can either already be one, or be a | 347 * Gets a [Directory] for [entry], which can either already be one, or be a |
| 346 * [String]. | 348 * [String]. |
| 347 */ | 349 */ |
| 348 Directory _getDirectory(entry) { | 350 Directory _getDirectory(entry) { |
| 349 if (entry is Directory) return entry; | 351 if (entry is Directory) return entry; |
| 350 return new Directory(entry); | 352 return new Directory(entry); |
| 351 } | 353 } |
| OLD | NEW |