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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | utils/pub/pub.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/package.dart
diff --git a/utils/pub/package.dart b/utils/pub/package.dart
index 0b1bcfa2d36dc32c3e19cc34e396f4a8df3ffec1..8a672f82ab0cb56bb91e295f66907d1736ff22c8 100644
--- a/utils/pub/package.dart
+++ b/utils/pub/package.dart
@@ -113,13 +113,28 @@ class Package implements Hashable {
});
readFuture.then((pubspec) {
- // TODO(rnystrom): Use YAML parser when ready. For now, it's just a flat
- // list of newline-separated strings.
- final dependencyNames = pubspec.split('\n').
- map((name) => name.trim()).
- filter((name) => (name != null) && (name != ''));
-
- completer.complete(dependencyNames);
+ if (pubspec.trim() == '') {
+ completer.complete(<String>[]);
+ return;
+ }
+
+ var parsedPubspec = loadYaml(pubspec);
+ if (parsedPubspec is! Map) {
+ completer.completeException('The pubspec must be a YAML mapping.');
+ }
+
+ if (!parsedPubspec.containsKey('dependencies')) {
+ completer.complete(<String>[]);
+ return;
+ }
+
+ var dependencies = parsedPubspec['dependencies'];
+ if (dependencies.some((e) => e is! String)) {
+ completer.completeException(
+ 'The pubspec dependencies must be a list of package names.');
+ }
+
+ completer.complete(dependencies);
});
return completer.future;
« 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