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

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

Issue 13332009: Make listDir and createSymlink synchronous in pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes 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/io.dart ('k') | utils/pub/path_source.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 package; 5 library package;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:pathos/path.dart' as path; 9 import 'package:pathos/path.dart' as path;
10 10
(...skipping 25 matching lines...) Expand all
36 36
37 /// The ids of the packages that this package depends on. This is what is 37 /// The ids of the packages that this package depends on. This is what is
38 /// specified in the pubspec when this package depends on another. 38 /// specified in the pubspec when this package depends on another.
39 List<PackageRef> get dependencies => pubspec.dependencies; 39 List<PackageRef> get dependencies => pubspec.dependencies;
40 40
41 /// Returns the path to the README file at the root of the entrypoint, or null 41 /// Returns the path to the README file at the root of the entrypoint, or null
42 /// if no README file is found. If multiple READMEs are found, this uses the 42 /// if no README file is found. If multiple READMEs are found, this uses the
43 /// same conventions as pub.dartlang.org for choosing the primary one: the 43 /// same conventions as pub.dartlang.org for choosing the primary one: the
44 /// README with the fewest extensions that is lexically ordered first is 44 /// README with the fewest extensions that is lexically ordered first is
45 /// chosen. 45 /// chosen.
46 Future<String> get readmePath { 46 String get readmePath {
47 return listDir(dir).then((entries) { 47 var readmes = listDir(dir).map(path.basename).
48 var readmes = entries.map(path.basename). 48 where((entry) => entry.contains(_README_REGEXP));
49 where((entry) => entry.contains(_README_REGEXP)); 49 if (readmes.isEmpty) return;
50 if (readmes.isEmpty) return;
51 50
52 return path.join(dir, readmes.min((readme1, readme2) { 51 return path.join(dir, readmes.min((readme1, readme2) {
53 var extensions1 = ".".allMatches(readme1).length; 52 var extensions1 = ".".allMatches(readme1).length;
54 var extensions2 = ".".allMatches(readme2).length; 53 var extensions2 = ".".allMatches(readme2).length;
55 var comparison = extensions1.compareTo(extensions2); 54 var comparison = extensions1.compareTo(extensions2);
56 if (comparison != 0) return comparison; 55 if (comparison != 0) return comparison;
57 return readme1.compareTo(readme2); 56 return readme1.compareTo(readme2);
58 })); 57 }));
59 });
60 } 58 }
61 59
62 /// Loads the package whose root directory is [packageDir]. [name] is the 60 /// Loads the package whose root directory is [packageDir]. [name] is the
63 /// expected name of that package (e.g. the name given in the dependency), or 61 /// expected name of that package (e.g. the name given in the dependency), or
64 /// `null` if the package being loaded is the entrypoint package. 62 /// `null` if the package being loaded is the entrypoint package.
65 Package.load(String name, String packageDir, SourceRegistry sources) 63 Package.load(String name, String packageDir, SourceRegistry sources)
66 : dir = packageDir, 64 : dir = packageDir,
67 pubspec = new Pubspec.load(name, packageDir, sources); 65 pubspec = new Pubspec.load(name, packageDir, sources);
68 66
69 /// Constructs a package with the given pubspec. The package will have no 67 /// Constructs a package with the given pubspec. The package will have no
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 205
208 class PubspecNameMismatchException implements Exception { 206 class PubspecNameMismatchException implements Exception {
209 final String expectedName; 207 final String expectedName;
210 final String actualName; 208 final String actualName;
211 209
212 PubspecNameMismatchException(this.expectedName, this.actualName); 210 PubspecNameMismatchException(this.expectedName, this.actualName);
213 211
214 String toString() => 'The name you specified for your dependency, ' 212 String toString() => 'The name you specified for your dependency, '
215 '"$expectedName", doesn\'t match the name "$actualName" in its pubspec.'; 213 '"$expectedName", doesn\'t match the name "$actualName" in its pubspec.';
216 } 214 }
OLDNEW
« no previous file with comments | « utils/pub/io.dart ('k') | utils/pub/path_source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698