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

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

Issue 13132002: Version 0.4.3.5 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/dart/
Patch Set: Created 7 years, 8 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 | « utils/pub/command_lish.dart ('k') | utils/pub/io.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/pathos/lib/path.dart' as path; 9 import '../../pkg/pathos/lib/path.dart' as path;
10 10
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 /// 67 ///
68 /// See also [installDependencies]. 68 /// See also [installDependencies].
69 Future<PackageId> install(PackageId id) { 69 Future<PackageId> install(PackageId id) {
70 var pendingOrCompleted = _installs[id]; 70 var pendingOrCompleted = _installs[id];
71 if (pendingOrCompleted != null) return pendingOrCompleted; 71 if (pendingOrCompleted != null) return pendingOrCompleted;
72 72
73 var packageDir = path.join(packagesDir, id.name); 73 var packageDir = path.join(packagesDir, id.name);
74 var future = defer(() { 74 var future = defer(() {
75 ensureDir(path.dirname(packageDir)); 75 ensureDir(path.dirname(packageDir));
76 76
77 if (dirExists(packageDir)) { 77 if (entryExists(packageDir)) {
78 // TODO(nweiz): figure out when to actually delete the directory, and 78 // TODO(nweiz): figure out when to actually delete the directory, and
79 // when we can just re-use the existing symlink. 79 // when 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 deleteDir(packageDir); 81 deleteEntry(packageDir);
82 } 82 }
83 83
84 if (id.source.shouldCache) { 84 if (id.source.shouldCache) {
85 return cache.install(id).then( 85 return cache.install(id).then(
86 (pkg) => createPackageSymlink(id.name, pkg.dir, packageDir)); 86 (pkg) => createPackageSymlink(id.name, pkg.dir, packageDir));
87 } else { 87 } else {
88 return id.source.install(id, packageDir).then((found) { 88 return id.source.install(id, packageDir).then((found) {
89 if (found) return null; 89 if (found) return null;
90 // TODO(nweiz): More robust error-handling. 90 // TODO(nweiz): More robust error-handling.
91 throw 'Package ${id.name} not found in source "${id.source.name}".'; 91 throw 'Package ${id.name} not found in source "${id.source.name}".';
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 "or adding a version constraint to use an older version of a " 203 "or adding a version constraint to use an older version of a "
204 "package."); 204 "package.");
205 } 205 }
206 }); 206 });
207 } 207 }
208 208
209 /// Loads the list of concrete package versions from the `pubspec.lock`, if it 209 /// Loads the list of concrete package versions from the `pubspec.lock`, if it
210 /// exists. If it doesn't, this completes to an empty [LockFile]. 210 /// exists. If it doesn't, this completes to an empty [LockFile].
211 LockFile loadLockFile() { 211 LockFile loadLockFile() {
212 var lockFilePath = path.join(root.dir, 'pubspec.lock'); 212 var lockFilePath = path.join(root.dir, 'pubspec.lock');
213 if (!fileExists(lockFilePath)) return new LockFile.empty(); 213 if (!entryExists(lockFilePath)) return new LockFile.empty();
214 return new LockFile.load(lockFilePath, cache.sources); 214 return new LockFile.load(lockFilePath, cache.sources);
215 } 215 }
216 216
217 /// Saves a list of concrete package versions to the `pubspec.lock` file. 217 /// Saves a list of concrete package versions to the `pubspec.lock` file.
218 void _saveLockFile(List<PackageId> packageIds) { 218 void _saveLockFile(List<PackageId> packageIds) {
219 var lockFile = new LockFile.empty(); 219 var lockFile = new LockFile.empty();
220 for (var id in packageIds) { 220 for (var id in packageIds) {
221 if (!id.isRoot) lockFile.packages[id.name] = id; 221 if (!id.isRoot) lockFile.packages[id.name] = id;
222 } 222 }
223 223
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 }); 291 });
292 }).toList()); 292 }).toList());
293 }).then(flatten); 293 }).then(flatten);
294 } 294 }
295 295
296 /// Creates a symlink to the `packages` directory in [dir]. Will replace one 296 /// Creates a symlink to the `packages` directory in [dir]. Will replace one
297 /// if already there. 297 /// if already there.
298 Future _linkSecondaryPackageDir(String dir) { 298 Future _linkSecondaryPackageDir(String dir) {
299 return defer(() { 299 return defer(() {
300 var symlink = path.join(dir, 'packages'); 300 var symlink = path.join(dir, 'packages');
301 // The order of if tests is significant here. fileExists() will return 301 if (entryExists(symlink)) deleteEntry(symlink);
302 // true for a symlink (broken or not) but deleteFile() cannot be used
303 // to delete a broken symlink on Windows. So we test for the directory
304 // first since deleteDir() does work on symlinks.
305 // TODO(rnystrom): Make deleteFile() work for symlinks on Windows so this
306 // doesn't matter.
307 if (dirExists(symlink)) {
308 deleteDir(symlink);
309 } else if (fileExists(symlink)) {
310 deleteFile(symlink);
311 }
312 return createSymlink(packagesDir, symlink, relative: true); 302 return createSymlink(packagesDir, symlink, relative: true);
313 }); 303 });
314 } 304 }
315 } 305 }
OLDNEW
« no previous file with comments | « utils/pub/command_lish.dart ('k') | utils/pub/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698