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

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

Issue 10534081: pub: treat a pubspec with just comments as empty (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: with tests Created 8 years, 5 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 | dart/utils/tests/pub/pubspec_test.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('pubspec'); 5 #library('pubspec');
6 6
7 #import('package.dart'); 7 #import('package.dart');
8 #import('source.dart'); 8 #import('source.dart');
9 #import('source_registry.dart'); 9 #import('source_registry.dart');
10 #import('utils.dart'); 10 #import('utils.dart');
(...skipping 24 matching lines...) Expand all
35 * Parses the pubspec whose text is [contents]. If the pubspec doesn't define 35 * Parses the pubspec whose text is [contents]. If the pubspec doesn't define
36 * version for itself, it defaults to [Version.none]. 36 * version for itself, it defaults to [Version.none].
37 */ 37 */
38 factory Pubspec.parse(String contents, SourceRegistry sources) { 38 factory Pubspec.parse(String contents, SourceRegistry sources) {
39 var version = Version.none; 39 var version = Version.none;
40 var dependencies = <PackageRef>[]; 40 var dependencies = <PackageRef>[];
41 41
42 if (contents.trim() == '') return new Pubspec.empty(); 42 if (contents.trim() == '') return new Pubspec.empty();
43 43
44 var parsedPubspec = loadYaml(contents); 44 var parsedPubspec = loadYaml(contents);
45 if (parsedPubspec == null) return new Pubspec.empty();
46
45 if (parsedPubspec is! Map) { 47 if (parsedPubspec is! Map) {
46 throw new FormatException('The pubspec must be a YAML mapping.'); 48 throw new FormatException('The pubspec must be a YAML mapping.');
47 } 49 }
48 50
49 if (parsedPubspec.containsKey('version')) { 51 if (parsedPubspec.containsKey('version')) {
50 version = new Version.parse(parsedPubspec['version']); 52 version = new Version.parse(parsedPubspec['version']);
51 } 53 }
52 54
53 if (parsedPubspec.containsKey('dependencies')) { 55 if (parsedPubspec.containsKey('dependencies')) {
54 var dependencyEntries = parsedPubspec['dependencies']; 56 var dependencyEntries = parsedPubspec['dependencies'];
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 source.validateDescription(description); 98 source.validateDescription(description);
97 99
98 dependencies.add(new PackageRef( 100 dependencies.add(new PackageRef(
99 source, versionConstraint, description)); 101 source, versionConstraint, description));
100 }); 102 });
101 } 103 }
102 104
103 return new Pubspec(version, dependencies); 105 return new Pubspec(version, dependencies);
104 } 106 }
105 } 107 }
OLDNEW
« no previous file with comments | « no previous file | dart/utils/tests/pub/pubspec_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698