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

Side by Side Diff: lib/src/command/cache_add.dart

Issue 1276673006: Make Source.getDirectory synchronous. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « no previous file | lib/src/command/list_package_dirs.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 pub.command.cache_add; 5 library pub.command.cache_add;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:pub_semver/pub_semver.dart'; 9 import 'package:pub_semver/pub_semver.dart';
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 var versions = pubspecs.map((pubspec) => pubspec.version) 63 var versions = pubspecs.map((pubspec) => pubspec.version)
64 .where(constraint.allows).toList(); 64 .where(constraint.allows).toList();
65 65
66 if (versions.isEmpty) { 66 if (versions.isEmpty) {
67 // TODO(rnystrom): Show most recent unmatching version? 67 // TODO(rnystrom): Show most recent unmatching version?
68 fail("Package $package has no versions that match $constraint."); 68 fail("Package $package has no versions that match $constraint.");
69 } 69 }
70 70
71 downloadVersion(version) async { 71 downloadVersion(version) async {
72 var id = new PackageId(package, source.name, version, package); 72 var id = new PackageId(package, source.name, version, package);
73 if (await cache.contains(id)) { 73 if (cache.contains(id)) {
74 // TODO(rnystrom): Include source and description if not hosted. 74 // TODO(rnystrom): Include source and description if not hosted.
75 // See solve_report.dart for code to harvest. 75 // See solve_report.dart for code to harvest.
76 log.message("Already cached ${id.name} ${id.version}."); 76 log.message("Already cached ${id.name} ${id.version}.");
77 return null; 77 return null;
78 } 78 }
79 79
80 // Download it. 80 // Download it.
81 await source.downloadToSystemCache(id); 81 await source.downloadToSystemCache(id);
82 } 82 }
83 83
84 if (argResults["all"]) { 84 if (argResults["all"]) {
85 // Install them in ascending order. 85 // Install them in ascending order.
86 versions.sort(); 86 versions.sort();
87 await Future.forEach(versions, downloadVersion); 87 await Future.forEach(versions, downloadVersion);
88 } else { 88 } else {
89 // Pick the best matching version. 89 // Pick the best matching version.
90 versions.sort(Version.prioritize); 90 versions.sort(Version.prioritize);
91 await downloadVersion(versions.last); 91 await downloadVersion(versions.last);
92 } 92 }
93 } 93 }
94 } 94 }
OLDNEW
« no previous file with comments | « no previous file | lib/src/command/list_package_dirs.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698