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

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

Issue 12295009: Recommit changing List.skip/take/revert returns Iterable and remove mappedBy. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Make Future.wait simpler. 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
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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 }).then(_installDependencies); 127 }).then(_installDependencies);
128 } 128 }
129 129
130 /// Removes the old packages directory, installs all dependencies listed in 130 /// Removes the old packages directory, installs all dependencies listed in
131 /// [packageVersions], and writes a [LockFile]. 131 /// [packageVersions], and writes a [LockFile].
132 Future _installDependencies(List<PackageId> packageVersions) { 132 Future _installDependencies(List<PackageId> packageVersions) {
133 return cleanDir(packagesDir).then((_) { 133 return cleanDir(packagesDir).then((_) {
134 return Future.wait(packageVersions.map((id) { 134 return Future.wait(packageVersions.map((id) {
135 if (id.isRoot) return new Future.immediate(id); 135 if (id.isRoot) return new Future.immediate(id);
136 return install(id); 136 return install(id);
137 })); 137 }).toList());
138 }).then(_saveLockFile) 138 }).then(_saveLockFile)
139 .then(_installSelfReference) 139 .then(_installSelfReference)
140 .then(_linkSecondaryPackageDirs); 140 .then(_linkSecondaryPackageDirs);
141 } 141 }
142 142
143 /// Traverses the root's package dependency graph and loads each of the 143 /// Traverses the root's package dependency graph and loads each of the
144 /// reached packages. This should only be called after the lockfile has been 144 /// reached packages. This should only be called after the lockfile has been
145 /// successfully generated. 145 /// successfully generated.
146 Future<List<Pubspec>> walkDependencies() { 146 Future<List<Pubspec>> walkDependencies() {
147 return defer(() { 147 return defer(() {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 return defer(() { 260 return defer(() {
261 if (!dirExists(dir)) return; 261 if (!dirExists(dir)) return;
262 return _linkSecondaryPackageDir(dir) 262 return _linkSecondaryPackageDir(dir)
263 .then((_) => _listDirWithoutPackages(dir)) 263 .then((_) => _listDirWithoutPackages(dir))
264 .then((files) { 264 .then((files) {
265 return Future.wait(files.map((file) { 265 return Future.wait(files.map((file) {
266 return defer(() { 266 return defer(() {
267 if (!dirExists(file)) return; 267 if (!dirExists(file)) return;
268 return _linkSecondaryPackageDir(file); 268 return _linkSecondaryPackageDir(file);
269 }); 269 });
270 })); 270 }).toList());
271 }); 271 });
272 }); 272 });
273 } 273 }
274 274
275 // TODO(nweiz): roll this into [listDir] in io.dart once issue 4775 is fixed. 275 // TODO(nweiz): roll this into [listDir] in io.dart once issue 4775 is fixed.
276 /// Recursively lists the contents of [dir], excluding hidden `.DS_Store` 276 /// Recursively lists the contents of [dir], excluding hidden `.DS_Store`
277 /// files and `package` files. 277 /// files and `package` files.
278 Future<List<String>> _listDirWithoutPackages(dir) { 278 Future<List<String>> _listDirWithoutPackages(dir) {
279 return listDir(dir).then((files) { 279 return listDir(dir).then((files) {
280 return Future.wait(files.map((file) { 280 return Future.wait(files.map((file) {
281 if (path.basename(file) == 'packages') return new Future.immediate([]); 281 if (path.basename(file) == 'packages') return new Future.immediate([]);
282 return defer(() { 282 return defer(() {
283 if (!dirExists(file)) return []; 283 if (!dirExists(file)) return [];
284 return _listDirWithoutPackages(file); 284 return _listDirWithoutPackages(file);
285 }).then((subfiles) { 285 }).then((subfiles) {
286 var fileAndSubfiles = [file]; 286 var fileAndSubfiles = [file];
287 fileAndSubfiles.addAll(subfiles); 287 fileAndSubfiles.addAll(subfiles);
288 return fileAndSubfiles; 288 return fileAndSubfiles;
289 }); 289 });
290 })); 290 }).toList());
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 to = path.join(dir, 'packages'); 297 var to = path.join(dir, 'packages');
298 if (entryExists(to)) return; 298 if (entryExists(to)) return;
299 return createSymlink(packagesDir, to); 299 return createSymlink(packagesDir, to);
300 }); 300 });
301 } 301 }
302 } 302 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698