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

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

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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/oauth2.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 library package; 5 library package;
6 6
7 import 'dart:async';
7 import 'io.dart'; 8 import 'io.dart';
8 import 'pubspec.dart'; 9 import 'pubspec.dart';
9 import 'source.dart'; 10 import 'source.dart';
10 import 'source_registry.dart'; 11 import 'source_registry.dart';
11 import 'version.dart'; 12 import 'version.dart';
12 13
13 /// A named, versioned, unit of code and resource reuse. 14 /// A named, versioned, unit of code and resource reuse.
14 class Package { 15 class Package {
15 /// Loads the package whose root directory is [packageDir]. [name] is the 16 /// Loads the package whose root directory is [packageDir]. [name] is the
16 /// expected name of that package (e.g. the name given in the dependency), or 17 /// expected name of that package (e.g. the name given in the dependency), or
17 /// null if the package being loaded is the entrypoint package. 18 /// null if the package being loaded is the entrypoint package.
18 static Future<Package> load(String name, String packageDir, 19 static Future<Package> load(String name, String packageDir,
19 SourceRegistry sources) { 20 SourceRegistry sources) {
20 var pubspecPath = join(packageDir, 'pubspec.yaml'); 21 var pubspecPath = join(packageDir, 'pubspec.yaml');
21 22
22 return fileExists(pubspecPath).chain((exists) { 23 return fileExists(pubspecPath).then((exists) {
23 if (!exists) throw new PubspecNotFoundException(name); 24 if (!exists) throw new PubspecNotFoundException(name);
24 return readTextFile(pubspecPath); 25 return readTextFile(pubspecPath);
25 }).transform((contents) { 26 }).then((contents) {
26 try { 27 try {
27 var pubspec = new Pubspec.parse(contents, sources); 28 var pubspec = new Pubspec.parse(contents, sources);
28 29
29 if (pubspec.name == null) throw new PubspecHasNoNameException(name); 30 if (pubspec.name == null) throw new PubspecHasNoNameException(name);
30 if (name != null && pubspec.name != name) { 31 if (name != null && pubspec.name != name) {
31 throw new PubspecNameMismatchException(name, pubspec.name); 32 throw new PubspecNameMismatchException(name, pubspec.name);
32 } 33 }
33 return new Package._(packageDir, pubspec); 34 return new Package._(packageDir, pubspec);
34 } on FormatException catch (ex) { 35 } on FormatException catch (ex) {
35 throw 'Could not parse $pubspecPath:\n${ex.message}'; 36 throw 'Could not parse $pubspecPath:\n${ex.message}';
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 180
180 class PubspecNameMismatchException implements Exception { 181 class PubspecNameMismatchException implements Exception {
181 final String expectedName; 182 final String expectedName;
182 final String actualName; 183 final String actualName;
183 184
184 PubspecNameMismatchException(this.expectedName, this.actualName); 185 PubspecNameMismatchException(this.expectedName, this.actualName);
185 186
186 String toString() => 'The name you specified for your dependency, ' 187 String toString() => 'The name you specified for your dependency, '
187 '"$expectedName", doesn\'t match the name "$actualName" in its pubspec.'; 188 '"$expectedName", doesn\'t match the name "$actualName" in its pubspec.';
188 } 189 }
OLDNEW
« no previous file with comments | « utils/pub/oauth2.dart ('k') | utils/pub/pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698