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. |