OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /// Helper functionality to make working with IO easier. | 5 /// Helper functionality to make working with IO easier. |
6 library pub.io; | 6 library pub.io; |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:collection'; | 9 import 'dart:collection'; |
10 import 'dart:convert'; | 10 import 'dart:convert'; |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 final bool runningFromTest = Platform.script.path.endsWith('.test.snapshot'); | 489 final bool runningFromTest = Platform.script.path.endsWith('.test.snapshot'); |
490 | 490 |
491 /// Whether pub is running from within the Dart SDK, as opposed to from the Dart | 491 /// Whether pub is running from within the Dart SDK, as opposed to from the Dart |
492 /// source repository. | 492 /// source repository. |
493 final bool runningFromSdk = | 493 final bool runningFromSdk = |
494 !runningFromTest && Platform.script.path.endsWith('.snapshot'); | 494 !runningFromTest && Platform.script.path.endsWith('.snapshot'); |
495 | 495 |
496 /// A regular expression to match the script path of a pub script running from | 496 /// A regular expression to match the script path of a pub script running from |
497 /// source in the Dart repo. | 497 /// source in the Dart repo. |
498 final _dartRepoRegExp = new RegExp( | 498 final _dartRepoRegExp = new RegExp( |
499 r"/third_party/pkg_tested/pub/(bin/pub.dart|test/.*_test\.dart)$"); | 499 r"/third_party/pkg_tested/pub/(" |
| 500 r"bin/pub\.dart" |
| 501 r"|" |
| 502 r"\.pub/pub\.test\.snapshot" |
| 503 r"|" |
| 504 r"test/.*_test\.dart" |
| 505 r")$"); |
500 | 506 |
501 /// Whether pub is running from source in the Dart repo. | 507 /// Whether pub is running from source in the Dart repo. |
502 /// | 508 /// |
503 /// This can happen when building Observatory, for example. | 509 /// This can happen when building Observatory, for example. |
504 final bool runningFromDartRepo = | 510 final bool runningFromDartRepo = |
505 Platform.script.path.contains(_dartRepoRegExp); | 511 Platform.script.path.contains(_dartRepoRegExp); |
506 | 512 |
507 /// Resolves [target] relative to the path to pub's `asset` directory. | 513 /// Resolves [target] relative to the path to pub's `asset` directory. |
508 String assetPath(String target) => runningFromSdk | 514 String assetPath(String target) => runningFromSdk |
509 ? sdkAssetPath(target) | 515 ? sdkAssetPath(target) |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 | 1065 |
1060 // TODO(rnystrom): Remove this and change to returning one string. | 1066 // TODO(rnystrom): Remove this and change to returning one string. |
1061 static List<String> _toLines(String output) { | 1067 static List<String> _toLines(String output) { |
1062 var lines = splitLines(output); | 1068 var lines = splitLines(output); |
1063 if (!lines.isEmpty && lines.last == "") lines.removeLast(); | 1069 if (!lines.isEmpty && lines.last == "") lines.removeLast(); |
1064 return lines; | 1070 return lines; |
1065 } | 1071 } |
1066 | 1072 |
1067 bool get success => exitCode == exit_codes.SUCCESS; | 1073 bool get success => exitCode == exit_codes.SUCCESS; |
1068 } | 1074 } |
OLD | NEW |