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

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

Issue 12280019: Revert "Support relative paths in path dependencies." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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/git_source.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 'dart:async'; 7 import 'dart:async';
8 8
9 import '../../pkg/path/lib/path.dart' as path; 9 import '../../pkg/path/lib/path.dart' as path;
10 10
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 ensureDir(path.dirname(packageDir)); 75 ensureDir(path.dirname(packageDir));
76 if (!dirExists(packageDir)) return; 76 if (!dirExists(packageDir)) return;
77 77
78 // TODO(nweiz): figure out when to actually delete the directory, and when 78 // TODO(nweiz): figure out when to actually delete the directory, and when
79 // we can just re-use the existing symlink. 79 // we can just re-use the existing symlink.
80 log.fine("Deleting package directory for ${id.name} before install."); 80 log.fine("Deleting package directory for ${id.name} before install.");
81 return deleteDir(packageDir); 81 return deleteDir(packageDir);
82 }).then((_) { 82 }).then((_) {
83 if (id.source.shouldCache) { 83 if (id.source.shouldCache) {
84 return cache.install(id).then( 84 return cache.install(id).then(
85 (pkg) => createPackageSymlink(id.name, packageDir, pkg.dir)); 85 (pkg) => createPackageSymlink(id.name, pkg.dir, packageDir));
86 } else { 86 } else {
87 return id.source.install(id, packageDir).then((found) { 87 return id.source.install(id, packageDir).then((found) {
88 if (found) return null; 88 if (found) return null;
89 // TODO(nweiz): More robust error-handling. 89 // TODO(nweiz): More robust error-handling.
90 throw 'Package ${id.name} not found in source "${id.source.name}".'; 90 throw 'Package ${id.name} not found in source "${id.source.name}".';
91 }); 91 });
92 } 92 }
93 }).then((_) => id.resolved); 93 }).then((_) => id.resolved);
94 94
95 _installs[id] = future; 95 _installs[id] = future;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 "package."); 202 "package.");
203 } 203 }
204 }); 204 });
205 } 205 }
206 206
207 /// Loads the list of concrete package versions from the `pubspec.lock`, if it 207 /// Loads the list of concrete package versions from the `pubspec.lock`, if it
208 /// exists. If it doesn't, this completes to an empty [LockFile]. 208 /// exists. If it doesn't, this completes to an empty [LockFile].
209 LockFile loadLockFile() { 209 LockFile loadLockFile() {
210 var lockFilePath = path.join(root.dir, 'pubspec.lock'); 210 var lockFilePath = path.join(root.dir, 'pubspec.lock');
211 if (!fileExists(lockFilePath)) return new LockFile.empty(); 211 if (!fileExists(lockFilePath)) return new LockFile.empty();
212 return new LockFile.load(lockFilePath, cache.sources); 212 return new LockFile.parse(readTextFile(lockFilePath), cache.sources);
213 } 213 }
214 214
215 /// Saves a list of concrete package versions to the `pubspec.lock` file. 215 /// Saves a list of concrete package versions to the `pubspec.lock` file.
216 void _saveLockFile(List<PackageId> packageIds) { 216 void _saveLockFile(List<PackageId> packageIds) {
217 var lockFile = new LockFile.empty(); 217 var lockFile = new LockFile.empty();
218 for (var id in packageIds) { 218 for (var id in packageIds) {
219 if (!id.isRoot) lockFile.packages[id.name] = id; 219 if (!id.isRoot) lockFile.packages[id.name] = id;
220 } 220 }
221 221
222 var lockFilePath = path.join(root.dir, 'pubspec.lock'); 222 var lockFilePath = path.join(root.dir, 'pubspec.lock');
223 writeTextFile(lockFilePath, lockFile.serialize()); 223 writeTextFile(lockFilePath, lockFile.serialize());
224 } 224 }
225 225
226 /// Installs a self-referential symlink in the `packages` directory that will 226 /// Installs a self-referential symlink in the `packages` directory that will
227 /// allow a package to import its own files using `package:`. 227 /// allow a package to import its own files using `package:`.
228 Future _installSelfReference(_) { 228 Future _installSelfReference(_) {
229 return defer(() { 229 return defer(() {
230 var linkPath = path.join(packagesDir, root.name); 230 var linkPath = path.join(packagesDir, root.name);
231 // Create the symlink if it doesn't exist. 231 // Create the symlink if it doesn't exist.
232 if (entryExists(linkPath)) return; 232 if (entryExists(linkPath)) return;
233 ensureDir(packagesDir); 233 ensureDir(packagesDir);
234 return createPackageSymlink(root.name, linkPath, root.dir, 234 return createPackageSymlink(root.name, root.dir, linkPath,
235 isSelfLink: true); 235 isSelfLink: true);
236 }); 236 });
237 } 237 }
238 238
239 /// If `bin/`, `test/`, or `example/` directories exist, symlink `packages/` 239 /// If `bin/`, `test/`, or `example/` directories exist, symlink `packages/`
240 /// into them so that their entrypoints can be run. Do the same for any 240 /// into them so that their entrypoints can be run. Do the same for any
241 /// subdirectories of `test/` and `example/`. 241 /// subdirectories of `test/` and `example/`.
242 Future _linkSecondaryPackageDirs(_) { 242 Future _linkSecondaryPackageDirs(_) {
243 var binDir = path.join(root.dir, 'bin'); 243 var binDir = path.join(root.dir, 'bin');
244 var exampleDir = path.join(root.dir, 'example'); 244 var exampleDir = path.join(root.dir, 'example');
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 fileAndSubfiles.addAll(subfiles); 287 fileAndSubfiles.addAll(subfiles);
288 return fileAndSubfiles; 288 return fileAndSubfiles;
289 }); 289 });
290 })); 290 }));
291 }).then(flatten); 291 }).then(flatten);
292 } 292 }
293 293
294 /// Creates a symlink to the `packages` directory in [dir] if none exists. 294 /// Creates a symlink to the `packages` directory in [dir] if none exists.
295 Future _linkSecondaryPackageDir(String dir) { 295 Future _linkSecondaryPackageDir(String dir) {
296 return defer(() { 296 return defer(() {
297 var symlink = path.join(dir, 'packages'); 297 var to = path.join(dir, 'packages');
298 if (entryExists(symlink)) return; 298 if (entryExists(to)) return;
299 return createSymlink(packagesDir, symlink); 299 return createSymlink(packagesDir, to);
300 }); 300 });
301 } 301 }
302 } 302 }
OLDNEW
« no previous file with comments | « no previous file | utils/pub/git_source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698