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

Side by Side Diff: 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: Created 8 years, 6 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 | no next file » | 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) {
nweiz 2012/07/16 19:34:02 Nit: we usually do single-line if statements when
46 // content just yaml comments
47 return new Pubspec.empty();
48 }
45 if (parsedPubspec is! Map) { 49 if (parsedPubspec is! Map) {
46 throw new FormatException('The pubspec must be a YAML mapping.'); 50 throw new FormatException('The pubspec must be a YAML mapping.');
47 } 51 }
48 52
49 if (parsedPubspec.containsKey('version')) { 53 if (parsedPubspec.containsKey('version')) {
50 version = new Version.parse(parsedPubspec['version']); 54 version = new Version.parse(parsedPubspec['version']);
51 } 55 }
52 56
53 if (parsedPubspec.containsKey('dependencies')) { 57 if (parsedPubspec.containsKey('dependencies')) {
54 var dependencyEntries = parsedPubspec['dependencies']; 58 var dependencyEntries = parsedPubspec['dependencies'];
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 source.validateDescription(description); 102 source.validateDescription(description);
99 103
100 dependencies.add(new PackageRef( 104 dependencies.add(new PackageRef(
101 name, source, Version.none, description)); 105 name, source, Version.none, description));
102 }); 106 });
103 } 107 }
104 108
105 return new Pubspec._(version, dependencies); 109 return new Pubspec._(version, dependencies);
106 } 110 }
107 } 111 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698