Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(854)

Unified Diff: utils/pub/io.dart

Issue 12782016: Switch pkg packages, pub, and dartdoc to use package: imports. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: utils/pub/io.dart
diff --git a/utils/pub/io.dart b/utils/pub/io.dart
index f4bb6de9e243da207bf8cd92126f792fea4efc90..fbeed38b347dc96772d4384730a855bbfe92ff02 100644
--- a/utils/pub/io.dart
+++ b/utils/pub/io.dart
@@ -11,14 +11,14 @@ import 'dart:isolate';
import 'dart:json';
import 'dart:uri';
-import '../../pkg/pathos/lib/path.dart' as path;
-import '../../pkg/http/lib/http.dart' show ByteStream;
+import 'package:pathos/path.dart' as path;
+import 'package:http/http.dart' show ByteStream;
import 'error_group.dart';
import 'exit_codes.dart' as exit_codes;
import 'log.dart' as log;
import 'utils.dart';
-export '../../pkg/http/lib/http.dart' show ByteStream;
+export 'package:http/http.dart' show ByteStream;
/// Returns whether or not [entry] is nested somewhere within [dir]. This just
/// performs a path comparison; it doesn't look at the actual filesystem.
@@ -310,6 +310,22 @@ String relativeToPub(String target) {
return path.normalize(path.join(utilDir, 'pub', target));
}
+/// Whether pub is running from within the Dart SDK, as opposed to from the Dart
+/// source repository.
+bool get runningFromSdk => path.dirname(relativeToPub('..')) == 'util';
Bob Nystrom 2013/03/26 01:55:44 Does pub itself need these or are they just for te
nweiz 2013/03/26 02:09:53 Done.
+
+// TODO(nweiz): use the built-in mechanism for accessing this once it exists
+// (issue 9119).
+/// The path to the `packages` directory from which pub loads its dependencies.
+String get packageRoot {
+ if (runningFromSdk) {
+ return path.absolute(relativeToPub(path.join('..', '..', 'packages')));
+ } else {
+ return path.absolute(path.join(
+ path.dirname(new Options().executable), '..', '..', 'packages'));
+ }
+}
+
// TODO(nweiz): add a ByteSink wrapper to make writing strings to stdout/stderr
// nicer.
« utils/pub/http.dart ('K') | « utils/pub/http.dart ('k') | utils/pub/lock_file.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698