Skip to content
This repository has been archived by the owner on May 29, 2023. It is now read-only.

Commit

Permalink
support path activations
Browse files Browse the repository at this point in the history
  • Loading branch information
devoncarew committed Apr 7, 2015
1 parent 766317c commit 70e8ff1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/pub_cache.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ class Application {
}
return null;
});
} else if (source == 'path') {
return new PackageRefImpl.path(key, m['version'], m['description']);
} else {
return new PackageRefImpl(source, key, m['version']);
}
Expand Down
24 changes: 24 additions & 0 deletions lib/src/impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class PackageRefImpl extends PackageRef {
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);
}

Expand All @@ -47,6 +51,25 @@ class GitPackageRefImpl extends PackageRefImpl {
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;
Expand All @@ -70,6 +93,7 @@ class DirectoryPackageRef extends PackageRef {
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;
Expand Down
3 changes: 2 additions & 1 deletion tool/travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ set -e

# 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 \
Expand Down

0 comments on commit 70e8ff1

Please sign in to comment.