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

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

Issue 11235067: Apply patch from other client. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 | « no previous file | utils/pub/pubspec.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 'io.dart'; 7 import 'io.dart';
8 import 'pubspec.dart'; 8 import 'pubspec.dart';
9 import 'source.dart'; 9 import 'source.dart';
10 import 'source_registry.dart'; 10 import 'source_registry.dart';
11 import 'version.dart'; 11 import 'version.dart';
12 12
13 /** 13 /**
14 * A named, versioned, unit of code and resource reuse. 14 * A named, versioned, unit of code and resource reuse.
15 */ 15 */
16 class Package { 16 class Package {
17 /** 17 /**
18 * Loads the package whose root directory is [packageDir]. [name] is the 18 * Loads the package whose root directory is [packageDir]. [name] is the
19 * expected name of that package (e.g. the name given in the dependency), or 19 * expected name of that package (e.g. the name given in the dependency), or
20 * null if the package being loaded is the entrypoint package. 20 * null if the package being loaded is the entrypoint package.
21 */ 21 */
22 static Future<Package> load(String name, String packageDir, 22 static Future<Package> load(String name, String packageDir,
23 SourceRegistry sources) { 23 SourceRegistry sources) {
24 var pubspecPath = join(packageDir, 'pubspec.yaml'); 24 var pubspecPath = join(packageDir, 'pubspec.yaml');
25 25
26 return fileExists(pubspecPath).chain((exists) { 26 return fileExists(pubspecPath).chain((exists) {
27 if (!exists) throw new PubspecNotFoundException(name); 27 if (!exists) throw new PubspecNotFoundException(name);
28 return readTextFile(pubspecPath); 28 return readTextFile(pubspecPath);
29 }).transform((contents) { 29 }).transform((contents) {
30 var pubspec = new Pubspec.parse(contents, sources); 30 try {
31 if (pubspec.name == null) throw new PubspecHasNoNameException(name); 31 var pubspec = new Pubspec.parse(contents, sources);
32 if (name != null && pubspec.name != name) { 32
33 throw new PubspecNameMismatchException(name, pubspec.name); 33 if (pubspec.name == null) throw new PubspecHasNoNameException(name);
34 if (name != null && pubspec.name != name) {
35 throw new PubspecNameMismatchException(name, pubspec.name);
36 }
37 return new Package._(packageDir, pubspec);
38 } on FormatException catch (ex) {
39 throw 'Could not parse $pubspecPath:\n${ex.message}';
34 } 40 }
35 return new Package._(packageDir, pubspec);
36 }); 41 });
37 } 42 }
38 43
39 /** 44 /**
40 * The path to the directory containing the package. 45 * The path to the directory containing the package.
41 */ 46 */
42 final String dir; 47 final String dir;
43 48
44 /** 49 /**
45 * The name of the package. 50 * The name of the package.
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 218
214 class PubspecNameMismatchException implements Exception { 219 class PubspecNameMismatchException implements Exception {
215 final String expectedName; 220 final String expectedName;
216 final String actualName; 221 final String actualName;
217 222
218 PubspecNameMismatchException(this.expectedName, this.actualName); 223 PubspecNameMismatchException(this.expectedName, this.actualName);
219 224
220 String toString() => 'The name you specified for your dependency, ' 225 String toString() => 'The name you specified for your dependency, '
221 '"$expectedName", doesn\'t match the name "$actualName" in its pubspec.'; 226 '"$expectedName", doesn\'t match the name "$actualName" in its pubspec.';
222 } 227 }
OLDNEW
« no previous file with comments | « no previous file | utils/pub/pubspec.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698