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

Unified Diff: utils/pub/io.dart

Issue 11280018: Remove support for old package layouts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Better error message. Created 8 years, 1 month 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
« no previous file with comments | « no previous file | utils/tests/pub/install/pub_install_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/io.dart
diff --git a/utils/pub/io.dart b/utils/pub/io.dart
index 3c8269396148bd8ee76955623be6c49bee5d0761..3296bb855f9562982e1b77a591362639a6d155c8 100644
--- a/utils/pub/io.dart
+++ b/utils/pub/io.dart
@@ -318,58 +318,29 @@ Future<File> createSymlink(from, to) {
}
/**
- * Creates a new symlink that creates an alias from the package [from] to [to],
- * both of which can be a [String], [File], or [Directory]. Returns a [Future]
- * which completes to the symlink file (i.e. [to]).
- *
- * Unlike [createSymlink], this has heuristics to detect if [from] is using
- * the old or new style of package layout. If it's using the new style, then
- * it will create a symlink to the "lib" directory contained inside that
- * package directory. Otherwise, it just symlinks to the package directory
- * itself.
- */
-// TODO(rnystrom): Remove this when old style packages are no longer supported.
-// See: http://code.google.com/p/dart/issues/detail?id=4964.
+ * Creates a new symlink that creates an alias from the `lib` directory of
+ * package [from] to [to], both of which can be a [String], [File], or
+ * [Directory]. Returns a [Future] which completes to the symlink file (i.e.
+ * [to]). If [from] does not have a `lib` directory, this shows a warning if
+ * appropriate and then does nothing.
+ */
Future<File> createPackageSymlink(String name, from, to,
{bool isSelfLink: false}) {
- // If from contains any Dart files at the top level (aside from build.dart)
- // we assume that means it's an old style package.
- return listDir(from).chain((contents) {
- var isOldStyle = contents.some(
- (file) => file.endsWith('.dart') && basename(file) != 'build.dart');
-
- if (isOldStyle) {
- if (isSelfLink) {
- printError('Warning: Package "$name" is using a deprecated layout.');
- printError('See http://www.dartlang.org/docs/pub-package-manager/'
- 'package-layout.html for details.');
-
- // Do not create self-links on old style packages.
- return new Future.immediate(to);
- } else {
- return createSymlink(from, to);
- }
+ // See if the package has a "lib" directory.
+ from = join(from, 'lib');
+ return dirExists(from).chain((exists) {
+ if (exists) return createSymlink(from, to);
+
+ // It's OK for the self link (i.e. the root package) to not have a lib
+ // directory since it may just be a leaf application that only has
+ // code in bin or web.
+ if (!isSelfLink) {
+ printError(
+ 'Warning: Package "$name" does not have a "lib" directory so you '
+ 'will not be able to import any libraries from it.');
}
- // It's a new style package, so symlink to the 'lib' directory. But only
- // if the package actually *has* one. Otherwise, we won't create a
- // symlink at all.
- from = join(from, 'lib');
- return dirExists(from).chain((exists) {
- if (exists) {
- return createSymlink(from, to);
- } else {
- // It's OK for the self link (i.e. the root package) to not have a lib
- // directory since it may just be a leaf application that only has
- // code in bin or web.
- if (!isSelfLink) {
- printError(
- 'Warning: Package "$name" does not have a "lib" directory.');
- }
-
- return new Future.immediate(to);
- }
- });
+ return new Future.immediate(to);
});
}
« no previous file with comments | « no previous file | utils/tests/pub/install/pub_install_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698