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

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

Issue 12285010: 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') | utils/pub/git_source.dart » ('J')
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, pkg.dir, packageDir)); 85 (pkg) => createPackageSymlink(id.name, packageDir, pkg.dir));
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.parse(readTextFile(lockFilePath), cache.sources); 212 return new LockFile.parse(lockFilePath, readTextFile(lockFilePath),
213 cache.sources);
nweiz 2013/02/15 23:09:24 Should this be LockFile.load, which just takes a p
Bob Nystrom 2013/02/16 00:09:57 Done.
213 } 214 }
214 215
215 /// Saves a list of concrete package versions to the `pubspec.lock` file. 216 /// Saves a list of concrete package versions to the `pubspec.lock` file.
216 void _saveLockFile(List<PackageId> packageIds) { 217 void _saveLockFile(List<PackageId> packageIds) {
217 var lockFile = new LockFile.empty(); 218 var lockFile = new LockFile.empty();
218 for (var id in packageIds) { 219 for (var id in packageIds) {
219 if (!id.isRoot) lockFile.packages[id.name] = id; 220 if (!id.isRoot) lockFile.packages[id.name] = id;
220 } 221 }
221 222
222 var lockFilePath = path.join(root.dir, 'pubspec.lock'); 223 var lockFilePath = path.join(root.dir, 'pubspec.lock');
223 writeTextFile(lockFilePath, lockFile.serialize()); 224 writeTextFile(lockFilePath, lockFile.serialize());
224 } 225 }
225 226
226 /// Installs a self-referential symlink in the `packages` directory that will 227 /// Installs a self-referential symlink in the `packages` directory that will
227 /// allow a package to import its own files using `package:`. 228 /// allow a package to import its own files using `package:`.
228 Future _installSelfReference(_) { 229 Future _installSelfReference(_) {
229 return defer(() { 230 return defer(() {
230 var linkPath = path.join(packagesDir, root.name); 231 var linkPath = path.join(packagesDir, root.name);
231 // Create the symlink if it doesn't exist. 232 // Create the symlink if it doesn't exist.
232 if (entryExists(linkPath)) return; 233 if (entryExists(linkPath)) return;
233 ensureDir(packagesDir); 234 ensureDir(packagesDir);
234 return createPackageSymlink(root.name, root.dir, linkPath, 235 return createPackageSymlink(root.name, linkPath, root.dir,
235 isSelfLink: true); 236 isSelfLink: true);
236 }); 237 });
237 } 238 }
238 239
239 /// If `bin/`, `test/`, or `example/` directories exist, symlink `packages/` 240 /// If `bin/`, `test/`, or `example/` directories exist, symlink `packages/`
240 /// into them so that their entrypoints can be run. Do the same for any 241 /// into them so that their entrypoints can be run. Do the same for any
241 /// subdirectories of `test/` and `example/`. 242 /// subdirectories of `test/` and `example/`.
242 Future _linkSecondaryPackageDirs(_) { 243 Future _linkSecondaryPackageDirs(_) {
243 var binDir = path.join(root.dir, 'bin'); 244 var binDir = path.join(root.dir, 'bin');
244 var exampleDir = path.join(root.dir, 'example'); 245 var exampleDir = path.join(root.dir, 'example');
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 fileAndSubfiles.addAll(subfiles); 288 fileAndSubfiles.addAll(subfiles);
288 return fileAndSubfiles; 289 return fileAndSubfiles;
289 }); 290 });
290 })); 291 }));
291 }).then(flatten); 292 }).then(flatten);
292 } 293 }
293 294
294 /// Creates a symlink to the `packages` directory in [dir] if none exists. 295 /// Creates a symlink to the `packages` directory in [dir] if none exists.
295 Future _linkSecondaryPackageDir(String dir) { 296 Future _linkSecondaryPackageDir(String dir) {
296 return defer(() { 297 return defer(() {
297 var to = path.join(dir, 'packages'); 298 var symlink = path.join(dir, 'packages');
298 if (entryExists(to)) return; 299 if (entryExists(symlink)) return;
299 return createSymlink(packagesDir, to); 300 return createSymlink(symlink, packagesDir);
300 }); 301 });
301 } 302 }
302 } 303 }
OLDNEW
« no previous file with comments | « no previous file | utils/pub/git_source.dart » ('j') | utils/pub/git_source.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698