Merge pull request #14 from dart-lang/devoncarew_support_path_activations
support path activations
diff --git a/lib/pub_cache.dart b/lib/pub_cache.dart
index a2c8b00..3f980e5 100644
--- a/lib/pub_cache.dart
+++ b/lib/pub_cache.dart
@@ -185,6 +185,8 @@
}
return null;
});
+ } else if (source == 'path') {
+ return new PackageRefImpl.path(key, m['version'], m['description']);
} else {
return new PackageRefImpl(source, key, m['version']);
}
diff --git a/lib/src/impl.dart b/lib/src/impl.dart
index fe6dfcb..a2b3e7f 100644
--- a/lib/src/impl.dart
+++ b/lib/src/impl.dart
@@ -29,6 +29,10 @@
return new GitPackageRefImpl(name, ver, description, resolver);
}
+ factory PackageRefImpl.path(String name, String ver, Map description) {
+ return new PathPackageRefImpl(name, ver, description);
+ }
+
Package resolve() => _resolver == null ? null : _resolver(this);
}
@@ -47,6 +51,25 @@
String get url => _description['url'];
}
+class PathPackageRefImpl extends PackageRefImpl {
+ final Map _description;
+
+ PathPackageRefImpl(String name, String ver, this._description) :
+ super('path', name, ver);
+
+ /// The path to the local package.
+ String get path => _description['path'];
+
+ bool get relative => _description['relative'] == true;
+
+ Package resolve() {
+ Directory dir = new Directory(path);
+ return dir.existsSync() ? new Package(dir, name, version) : null;
+ }
+}
+
+/// A reference to a package in the pub cache (for instance, something in
+/// `~/.pub-cache/hosted/pub.dartlang.org/`).
class DirectoryPackageRef extends PackageRef {
final String sourceType;
final Directory directory;
@@ -70,6 +93,7 @@
Package resolve() => new Package(directory, name, version);
}
+/// A reference to a package in the pub cache; something in `~/.pub-cache/git/`.
class GitDirectoryPackageRef extends PackageRef {
final String sourceType;
final Directory directory;
diff --git a/tool/travis.sh b/tool/travis.sh
index 8914355..dc1d87b 100755
--- a/tool/travis.sh
+++ b/tool/travis.sh
@@ -9,7 +9,8 @@
# Activate some packages for use while running tests.
pub global activate dart_coveralls
-pub global activate --source git https://github.com/dart-lang/pub_cache.git
+pub global activate --source git https://github.com/dart-lang/test.git
+pub global activate --source path .
# Verify that the libraries are error free.
dartanalyzer --fatal-warnings \