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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 if (workingDir != null) { | 499 if (workingDir != null) { |
500 options.workingDirectory = _getDirectory(workingDir).path; | 500 options.workingDirectory = _getDirectory(workingDir).path; |
501 } | 501 } |
502 options.environment = environment; | 502 options.environment = environment; |
503 | 503 |
504 var future = Process.run(executable, args, options); | 504 var future = Process.run(executable, args, options); |
505 return future.transform((result) { | 505 return future.transform((result) { |
506 // TODO(rnystrom): Remove this and change to returning one string. | 506 // TODO(rnystrom): Remove this and change to returning one string. |
507 List<String> toLines(String output) { | 507 List<String> toLines(String output) { |
508 var lines = output.split(NEWLINE_PATTERN); | 508 var lines = output.split(NEWLINE_PATTERN); |
509 if (!lines.isEmpty() && lines.last() == "") lines.removeLast(); | 509 if (!lines.isEmpty && lines.last() == "") lines.removeLast(); |
510 return lines; | 510 return lines; |
511 } | 511 } |
512 return new PubProcessResult(toLines(result.stdout), | 512 return new PubProcessResult(toLines(result.stdout), |
513 toLines(result.stderr), | 513 toLines(result.stderr), |
514 result.exitCode); | 514 result.exitCode); |
515 }); | 515 }); |
516 } | 516 } |
517 | 517 |
518 /** | 518 /** |
519 * Wraps [input] to provide a timeout. If [input] completes before | 519 * Wraps [input] to provide a timeout. If [input] completes before |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 return new Directory(entry); | 748 return new Directory(entry); |
749 } | 749 } |
750 | 750 |
751 /** | 751 /** |
752 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. | 752 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. |
753 */ | 753 */ |
754 Uri _getUri(uri) { | 754 Uri _getUri(uri) { |
755 if (uri is Uri) return uri; | 755 if (uri is Uri) return uri; |
756 return new Uri.fromString(uri); | 756 return new Uri.fromString(uri); |
757 } | 757 } |
OLD | NEW |