Index: sdk/lib/_internal/pub/lib/src/pub_package_provider.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/pub_package_provider.dart b/sdk/lib/_internal/pub/lib/src/pub_package_provider.dart |
index b1c2821e17855a28ef2fbe4c7b9ef5162c7e1c11..0c4357196b9fba61453800d5b2b85fbbed2b611e 100644 |
--- a/sdk/lib/_internal/pub/lib/src/pub_package_provider.dart |
+++ b/sdk/lib/_internal/pub/lib/src/pub_package_provider.dart |
@@ -10,14 +10,10 @@ import 'package:barback/barback.dart'; |
import 'package:path/path.dart' as path; |
import 'entrypoint.dart'; |
-import 'io.dart'; |
/// An implementation of barback's [PackageProvider] interface so that barback |
/// can assets within pub packages. |
class PubPackageProvider implements PackageProvider { |
- /// The [Entrypoint] package being served. |
- final Entrypoint _entrypoint; |
- |
/// Maps the names of all of the packages in [_entrypoint]'s transitive |
/// dependency graph to the local path of the directory for that package. |
final Map<String, String> _packageDirs; |
@@ -30,7 +26,6 @@ class PubPackageProvider implements PackageProvider { |
// Cache package directories up front so we can have synchronous access |
// to them. |
- // TODO(rnystrom): Handle missing or out of date lockfile. |
var futures = []; |
entrypoint.loadLockFile().packages.forEach((name, package) { |
var source = entrypoint.cache.sources[package.source]; |
@@ -40,51 +35,16 @@ class PubPackageProvider implements PackageProvider { |
}); |
return Future.wait(futures).then((_) { |
- return new PubPackageProvider._(entrypoint, packageDirs); |
+ return new PubPackageProvider._(packageDirs); |
}); |
} |
- PubPackageProvider._(this._entrypoint, this._packageDirs); |
+ PubPackageProvider._(this._packageDirs); |
Iterable<String> get packages => _packageDirs.keys; |
- /// Lists all of the visible files in [package]. |
- /// |
- /// This is the recursive contents of the "asset" and "lib" directories (if |
- /// present). If [package] is the entrypoint package, it also includes the |
- /// contents of "web". |
- List<AssetId> listAssets(String package) { |
- var files = <AssetId>[]; |
- |
- addFiles(String dirPath) { |
- var packageDir = _packageDirs[package]; |
- var dir = path.join(packageDir, dirPath); |
- if (!dirExists(dir)) return; |
- for (var entry in listDir(dir, recursive: true)) { |
- // Ignore "packages" symlinks if there. |
- if (path.split(entry).contains("packages")) continue; |
- |
- // Skip directories. |
- if (!fileExists(entry)) continue; |
- |
- // AssetId paths use "/" on all platforms. |
- var relative = path.relative(entry, from: packageDir); |
- relative = path.toUri(relative).path; |
- files.add(new AssetId(package, relative)); |
- } |
- } |
- |
- // Expose the "asset" and "lib" directories. |
- addFiles("asset"); |
- addFiles("lib"); |
- |
- // The entrypoint's "web" directory is also visible. |
- if (package == _entrypoint.root.name) { |
- addFiles("web"); |
- } |
- |
- return files; |
- } |
+ /// Gets the root directory of [package]. |
+ String getPackageDir(String package) => _packageDirs[package]; |
// TODO(rnystrom): Actually support transformers. |
Iterable<Iterable<Transformer>> getTransformers(String package) => []; |