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

Unified Diff: sdk/lib/_internal/pub/lib/src/entrypoint.dart

Issue 110013003: Issue 15037. Warn users if they have “assets” dir anywhere inside “web” dir (http://dartbug.com/150… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Escape "\" in RegExps. Created 7 years 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: sdk/lib/_internal/pub/lib/src/entrypoint.dart
diff --git a/sdk/lib/_internal/pub/lib/src/entrypoint.dart b/sdk/lib/_internal/pub/lib/src/entrypoint.dart
index 3882f2e5714535acd1e8ec06453d2264391f7d3a..918736aaca12aded869b11e594d6d09c660afc06 100644
--- a/sdk/lib/_internal/pub/lib/src/entrypoint.dart
+++ b/sdk/lib/_internal/pub/lib/src/entrypoint.dart
@@ -211,7 +211,7 @@ class Entrypoint {
/// Gets dependencies if the lockfile is out of date with respect to the
/// pubspec.
- Future ensureLockFileIsUpToDate() {
+ Future _ensureLockFileIsUpToDate() {
return syncFuture(() {
var lockFile = loadLockFile();
@@ -248,19 +248,42 @@ class Entrypoint {
});
}
+ /// Warns users if they have directory or file named `assets` _anywhere_
+ /// inside `web` directory.
+ void _warnOnAssetsPaths() {
+ var webDir = path.join(root.dir, 'web');
+ if (!dirExists(webDir)) return;
+
+ listDir(webDir, recursive: true)
+ .where((p) => path.basename(p) == 'assets')
+ .forEach((p) {
+ var assetsPath = path.relative(p, from: root.dir);
+ log.warning(
+ 'Warning: Pub reserves paths containing "assets" for using assets '
+ 'from packages. Please rename the path "$assetsPath".');
+ });
+ }
+
+ /// Loads the package graph for the application and all of its transitive
+ /// dependencies. Before loading makes sure the lockfile and dependencies are
+ /// installed and up to date.
+ Future<PackageGraph> loadPackageGraph() =>
+ _ensureLockFileIsUpToDate()
+ .then((_) {
+ _warnOnAssetsPaths();
+ return _loadPackageGraph();
+ });
+
/// Loads the package graph for the application and all of its transitive
/// dependencies.
- Future<PackageGraph> loadPackageGraph() {
+ Future<PackageGraph> _loadPackageGraph() {
var lockFile = loadLockFile();
return Future.wait(lockFile.packages.values.map((id) {
var source = cache.sources[id.source];
return source.getDirectory(id)
.then((dir) => new Package.load(id.name, dir, cache.sources));
})).then((packages) {
- var packageMap = <String, Package>{};
- for (var package in packages) {
- packageMap[package.name] = package;
- }
+ var packageMap = new Map.fromIterable(packages, key: (p) => p.name);
packageMap[root.name] = root;
return new PackageGraph(this, lockFile, packageMap);
});
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/command/serve.dart ('k') | sdk/lib/_internal/pub/test/build/warns_on_assets_paths_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698