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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 // directory since it may just be a leaf application that only has | 374 // directory since it may just be a leaf application that only has |
375 // code in bin or web. | 375 // code in bin or web. |
376 if (!isSelfLink) { | 376 if (!isSelfLink) { |
377 log.warning('Warning: Package "$name" does not have a "lib" directory so ' | 377 log.warning('Warning: Package "$name" does not have a "lib" directory so ' |
378 'you will not be able to import any libraries from it.'); | 378 'you will not be able to import any libraries from it.'); |
379 } | 379 } |
380 } | 380 } |
381 | 381 |
382 /// Whether pub is running from within the Dart SDK, as opposed to from the Dart | 382 /// Whether pub is running from within the Dart SDK, as opposed to from the Dart |
383 /// source repository. | 383 /// source repository. |
384 bool get runningFromSdk => path.extension(Platform.script) == '.snapshot'; | 384 bool get runningFromSdk => |
| 385 path.extension(Platform.script.toFilePath()) == '.snapshot'; |
385 | 386 |
386 /// Resolves [target] relative to the path to pub's `resource` directory. | 387 /// Resolves [target] relative to the path to pub's `resource` directory. |
387 String resourcePath(String target) { | 388 String resourcePath(String target) { |
388 if (runningFromSdk) { | 389 if (runningFromSdk) { |
389 return path.join( | 390 return path.join( |
390 sdk.rootDirectory, 'lib', '_internal', 'pub', 'resource', target); | 391 sdk.rootDirectory, 'lib', '_internal', 'pub', 'resource', target); |
391 } else { | 392 } else { |
392 return path.join( | 393 return path.join( |
393 path.dirname(libraryPath('pub.io')), '..', '..', 'resource', target); | 394 path.dirname(libraryPath('pub.io')), '..', '..', 'resource', target); |
394 } | 395 } |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 const PubProcessResult(this.stdout, this.stderr, this.exitCode); | 835 const PubProcessResult(this.stdout, this.stderr, this.exitCode); |
835 | 836 |
836 bool get success => exitCode == 0; | 837 bool get success => exitCode == 0; |
837 } | 838 } |
838 | 839 |
839 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. | 840 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. |
840 Uri _getUri(uri) { | 841 Uri _getUri(uri) { |
841 if (uri is Uri) return uri; | 842 if (uri is Uri) return uri; |
842 return Uri.parse(uri); | 843 return Uri.parse(uri); |
843 } | 844 } |
OLD | NEW |