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

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

Issue 10174029: Use YAML as the format for the pubspec file. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review change Created 8 years, 7 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 | « no previous file | 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 /** 5 /**
6 * A named, versioned, unit of code and resource reuse. 6 * A named, versioned, unit of code and resource reuse.
7 */ 7 */
8 class Package implements Hashable { 8 class Package implements Hashable {
9 /** 9 /**
10 * Loads the package whose root directory is [packageDir]. 10 * Loads the package whose root directory is [packageDir].
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 final readFuture = readTextFile(path); 106 final readFuture = readTextFile(path);
107 readFuture.handleException((error) { 107 readFuture.handleException((error) {
108 // If there is no pubspec, we implicitly treat that as a package with no 108 // If there is no pubspec, we implicitly treat that as a package with no
109 // dependencies. 109 // dependencies.
110 // TODO(rnystrom): Distinguish file not found from other real errors. 110 // TODO(rnystrom): Distinguish file not found from other real errors.
111 completer.complete(<String>[]); 111 completer.complete(<String>[]);
112 return true; 112 return true;
113 }); 113 });
114 114
115 readFuture.then((pubspec) { 115 readFuture.then((pubspec) {
116 // TODO(rnystrom): Use YAML parser when ready. For now, it's just a flat 116 if (pubspec.trim() == '') {
117 // list of newline-separated strings. 117 completer.complete(<String>[]);
118 final dependencyNames = pubspec.split('\n'). 118 return;
119 map((name) => name.trim()). 119 }
120 filter((name) => (name != null) && (name != ''));
121 120
122 completer.complete(dependencyNames); 121 var parsedPubspec = loadYaml(pubspec);
122 if (parsedPubspec is! Map) {
123 completer.completeException('The pubspec must be a YAML mapping.');
124 }
125
126 if (!parsedPubspec.containsKey('dependencies')) {
127 completer.complete(<String>[]);
128 return;
129 }
130
131 var dependencies = parsedPubspec['dependencies'];
132 if (dependencies.some((e) => e is! String)) {
133 completer.completeException(
134 'The pubspec dependencies must be a list of package names.');
135 }
136
137 completer.complete(dependencies);
123 }); 138 });
124 139
125 return completer.future; 140 return completer.future;
126 } 141 }
127 } 142 }
OLDNEW
« no previous file with comments | « no previous file | utils/pub/pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698