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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
478 /// Whether the current process is one of pub's test files. | 478 /// Whether the current process is one of pub's test files. |
479 /// | 479 /// |
480 /// This works because an actual pub executable that imports this will always | 480 /// This works because an actual pub executable that imports this will always |
481 /// start with "pub". | 481 /// start with "pub". |
482 final bool runningAsTest = | 482 final bool runningAsTest = |
483 !path.url.basename(Platform.script.path).startsWith('pub.'); | 483 !path.url.basename(Platform.script.path).startsWith('pub.'); |
484 | 484 |
485 /// Whether the current process is a pub subprocess being run from a test. | 485 /// Whether the current process is a pub subprocess being run from a test. |
486 /// | 486 /// |
487 /// This works because when running from tests, pub always uses a snapshot named | 487 /// This works because when running from tests, pub always uses a snapshot named |
488 /// "pub.test.snapshot", which is not used outside of tests. | 488 /// "pub.test.snapshot", which is not used outside of tests. |
Bob Nystrom
2015/06/26 16:41:16
Update the doc comment.
nweiz
2015/06/26 19:49:10
Done.
| |
489 final bool runningFromTest = Platform.script.path.endsWith('.test.snapshot'); | 489 final bool runningFromTest = Platform.environment.containsKey('_PUB_TESTING'); |
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/pub/(" | 499 r"/third_party/pkg/pub/(" |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1065 | 1065 |
1066 // TODO(rnystrom): Remove this and change to returning one string. | 1066 // TODO(rnystrom): Remove this and change to returning one string. |
1067 static List<String> _toLines(String output) { | 1067 static List<String> _toLines(String output) { |
1068 var lines = splitLines(output); | 1068 var lines = splitLines(output); |
1069 if (!lines.isEmpty && lines.last == "") lines.removeLast(); | 1069 if (!lines.isEmpty && lines.last == "") lines.removeLast(); |
1070 return lines; | 1070 return lines; |
1071 } | 1071 } |
1072 | 1072 |
1073 bool get success => exitCode == exit_codes.SUCCESS; | 1073 bool get success => exitCode == exit_codes.SUCCESS; |
1074 } | 1074 } |
OLD | NEW |