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

Unified Diff: utils/pub/path_source.dart

Issue 12285010: Support relative paths in path dependencies. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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/path_source.dart
diff --git a/utils/pub/path_source.dart b/utils/pub/path_source.dart
index 123a3086c2ed0b3a8c5d546e6a12521cf3e897d2..3c62c5c9db6436a70d331ae741f08c2c46762e1c 100644
--- a/utils/pub/path_source.dart
+++ b/utils/pub/path_source.dart
@@ -29,21 +29,33 @@ class PathSource extends Source {
});
}
- Future<bool> install(PackageId id, String path) {
+ Future<bool> install(PackageId id, String destination) {
return defer(() {
try {
_validatePath(id.name, id.description);
} on FormatException catch(err) {
return false;
}
- return createPackageSymlink(id.name, id.description, path);
+
+ return createPackageSymlink(id.name, destination, id.description,
+ relative: true);
nweiz 2013/02/15 23:09:24 This should be relative iff the path the user spec
Bob Nystrom 2013/02/16 00:09:57 Done.
}).then((_) => true);
}
- void validateDescription(description, {bool fromLockFile: false}) {
+ dynamic parseDescription(String containingPath, description,
+ {bool fromLockFile: false}) {
if (description is! String) {
throw new FormatException("The description must be a path string.");
}
+
+ if (path.isRelative(description)) {
+ // Can't handle relative paths coming from pubspecs that are not on the
+ // local file system.
nweiz 2013/02/15 23:09:24 Can this ever happen in practice? If so, we should
Bob Nystrom 2013/02/16 00:09:57 If a hosted package had a path dependency (which i
nweiz 2013/02/16 01:02:14 What if a remote git dependency has a path depende
Bob Nystrom 2013/02/16 01:19:03 I believe that will get installed locally, and the
nweiz 2013/02/16 01:33:11 That sounds like something else we should throw a
+ assert(containingPath != null);
+ description = path.join(path.dirname(containingPath), description);
+ }
+
+ return description;
}
/// Ensures that [dir] is a valid path. It must be an absolute path that

Powered by Google App Engine
This is Rietveld 408576698