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

Side by Side Diff: utils/pub/entrypoint.dart

Issue 10907036: Hide self-referential symlinks behind a flag in pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | utils/pub/pub.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #library('entrypoint'); 5 #library('entrypoint');
6 6
7 #import('io.dart'); 7 #import('io.dart');
8 #import('lock_file.dart'); 8 #import('lock_file.dart');
9 #import('package.dart'); 9 #import('package.dart');
10 #import('root_source.dart'); 10 #import('root_source.dart');
(...skipping 13 matching lines...) Expand all
24 * point either to the [SystemCache] or to some other location on the local 24 * point either to the [SystemCache] or to some other location on the local
25 * filesystem. 25 * filesystem.
26 * 26 *
27 * While entrypoints are typically applications, a pure library package may end 27 * While entrypoints are typically applications, a pure library package may end
28 * up being used as an entrypoint. Also, a single package may be used as an 28 * up being used as an entrypoint. Also, a single package may be used as an
29 * entrypoint in one context but not in another. For example, a package that 29 * entrypoint in one context but not in another. For example, a package that
30 * contains a reusable library may not be the entrypoint when used by an app, 30 * contains a reusable library may not be the entrypoint when used by an app,
31 * but may be the entrypoint when you're running its tests. 31 * but may be the entrypoint when you're running its tests.
32 */ 32 */
33 class Entrypoint { 33 class Entrypoint {
34 // TODO(rnystrom): Get rid of this when #4820 is fixed.
35 static bool installSelfLink = false;
36
34 /** 37 /**
35 * The root package this entrypoint is associated with. 38 * The root package this entrypoint is associated with.
36 */ 39 */
37 final Package root; 40 final Package root;
38 41
39 /** 42 /**
40 * The system-wide cache which caches packages that need to be fetched over 43 * The system-wide cache which caches packages that need to be fetched over
41 * the network. 44 * the network.
42 */ 45 */
43 final SystemCache cache; 46 final SystemCache cache;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 return writeTextFile(join(root.dir, 'pubspec.lock'), lockFile.serialize()); 219 return writeTextFile(join(root.dir, 'pubspec.lock'), lockFile.serialize());
217 } 220 }
218 221
219 /** 222 /**
220 * Installs a self-referential symlink in the `packages` directory that will 223 * Installs a self-referential symlink in the `packages` directory that will
221 * allow a package to import its own files using `package:`. 224 * allow a package to import its own files using `package:`.
222 */ 225 */
223 Future _installSelfReference(_) { 226 Future _installSelfReference(_) {
224 var linkPath = join(path, root.name); 227 var linkPath = join(path, root.name);
225 return exists(linkPath).chain((exists) { 228 return exists(linkPath).chain((exists) {
226 if (exists) return new Future.immediate(null); 229 if (installSelfLink) {
227 return ensureDir(path).chain((_) => createSymlink(root.dir, linkPath)); 230 // Create the symlink if it doesn't exist.
231 if (exists) return new Future.immediate(null);
232 return ensureDir(path).chain((_) => createSymlink(root.dir, linkPath));
233 } else {
234 // TODO(rnystrom): Get rid of this branch when #4820 is fixed.
235 // Delete the old one if it's there.
236 return ensureDir(path).chain((_) {
237 if (!exists) return new Future.immediate(null);
238 return deleteDir(linkPath);
239 });
240 }
228 }); 241 });
229 } 242 }
230 243
231 /** 244 /**
232 * If `bin/`, `test/`, or `example/` directories exist, symlink `packages/` 245 * If `bin/`, `test/`, or `example/` directories exist, symlink `packages/`
233 * into them so that their entrypoints can be run. Do the same for any 246 * into them so that their entrypoints can be run. Do the same for any
234 * subdirectories of `test/` and `example/`. 247 * subdirectories of `test/` and `example/`.
235 */ 248 */
236 Future _linkSecondaryPackageDirs(_) { 249 Future _linkSecondaryPackageDirs(_) {
237 var binDir = join(root.dir, 'bin'); 250 var binDir = join(root.dir, 'bin');
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 }); 323 });
311 } 324 }
312 325
313 return future.transform((_) { 326 return future.transform((_) {
314 if (root.pubspec.name != null) return; 327 if (root.pubspec.name != null) return;
315 throw '"pubspec.yaml" is missing the required "name" field (e.g. "name: ' 328 throw '"pubspec.yaml" is missing the required "name" field (e.g. "name: '
316 '${root.name}").'; 329 '${root.name}").';
317 }); 330 });
318 } 331 }
319 } 332 }
OLDNEW
« no previous file with comments | « no previous file | utils/pub/pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698