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

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

Issue 10214006: Refactor command code and add support for --help and --version. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase. Created 8 years, 7 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_version.dart ('k') | 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 /** 5 /**
6 * A named, versioned, unit of code and resource reuse. 6 * A named, versioned, unit of code and resource reuse.
7 */ 7 */
8 class Package implements Hashable { 8 class Package implements Hashable {
9 /** 9 /**
10 * Loads the package whose root directory is [packageDir]. 10 * Loads the package whose root directory is [packageDir].
(...skipping 28 matching lines...) Expand all
39 * Constructs a package. This should not be called directly. Instead, acquire 39 * Constructs a package. This should not be called directly. Instead, acquire
40 * packages from [load()]. 40 * packages from [load()].
41 */ 41 */
42 Package._(String dir, this.dependencies) 42 Package._(String dir, this.dependencies)
43 : dir = dir, 43 : dir = dir,
44 name = basename(dir); 44 name = basename(dir);
45 45
46 /** 46 /**
47 * Reads and returns all of the packages this package immediately depends on. 47 * Reads and returns all of the packages this package immediately depends on.
48 */ 48 */
49 Future<Collection<Package>> loadDependencies() { 49 Future<Collection<Package>> loadDependencies(PackageCache cache) {
50 return Futures.wait(dependencies.map((name) => cache.find(name))); 50 return Futures.wait(dependencies.map((name) => cache.find(name)));
51 } 51 }
52 52
53 /** 53 /**
54 * Walks the entire dependency graph starting at this package and returns a 54 * Walks the entire dependency graph starting at this package and returns a
55 * [Set] of all of the packages dependend on by this one, directly or 55 * [Set] of all of the packages dependend on by this one, directly or
56 * indirectly. This package is included in the result set. 56 * indirectly. This package is included in the result set.
57 */ 57 */
58 Future<Set<Package>> traverseDependencies() { 58 Future<Set<Package>> traverseDependencies(PackageCache cache) {
59 final completer = new Completer<Set<Package>>(); 59 final completer = new Completer<Set<Package>>();
60 final packages = new Set<Package>(); 60 final packages = new Set<Package>();
61 61
62 var pendingAsyncCalls = 0; 62 var pendingAsyncCalls = 0;
63 63
64 walkPackage(Package package) { 64 walkPackage(Package package) {
65 // Skip packages we've already traversed. 65 // Skip packages we've already traversed.
66 if (packages.contains(package)) return; 66 if (packages.contains(package)) return;
67 67
68 // Add the package. 68 // Add the package.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 completer.completeException( 133 completer.completeException(
134 'The pubspec dependencies must be a list of package names.'); 134 'The pubspec dependencies must be a list of package names.');
135 } 135 }
136 136
137 completer.complete(dependencies); 137 completer.complete(dependencies);
138 }); 138 });
139 139
140 return completer.future; 140 return completer.future;
141 } 141 }
142 } 142 }
OLDNEW
« no previous file with comments | « utils/pub/command_version.dart ('k') | utils/pub/pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698