Chromium Code Reviews| Index: utils/pub/lock_file.dart |
| =================================================================== |
| --- utils/pub/lock_file.dart (revision 17925) |
| +++ utils/pub/lock_file.dart (working copy) |
| @@ -13,6 +13,10 @@ |
| /// A parsed and validated `pubspec.lock` file. |
| class LockFile { |
| + |
| + /// comment to append at start of lock file |
| + static final comment = "# Generated by pub. See: http://pub.dartlang.org/doc/glossary.html#lockfile"; |
|
Bob Nystrom
2013/01/31 22:17:44
It's probably not worth making a constant for this
keertip
2013/01/31 22:40:41
Done.
|
| + |
| /// The packages this lockfile pins. |
| Map<String, PackageId> packages; |
| @@ -26,9 +30,9 @@ |
| var packages = <String, PackageId>{}; |
| if (contents.trim() == '') return new LockFile.empty(); |
| + // remove comment before parsing |
| + var parsed = loadYaml(contents.replaceAll(comment, '')); |
|
Bob Nystrom
2013/01/31 22:17:44
This shouldn't be necessary. YAML supports comment
keertip
2013/01/31 22:40:41
Removed.
On 2013/01/31 22:17:44, Bob Nystrom wrot
|
| - var parsed = loadYaml(contents); |
| - |
| if (parsed.containsKey('packages')) { |
| var packageEntries = parsed['packages']; |
| @@ -85,6 +89,7 @@ |
| // TODO(nweiz): Serialize using the YAML library once it supports |
| // serialization. For now, we use JSON, since it's a subset of YAML anyway. |
| - return json.stringify({'packages': packagesObj}); |
| + var lockFileString = json.stringify({'packages': packagesObj}); |
| + return '$comment $lockFileString'; |
|
Bob Nystrom
2013/01/31 22:17:44
I'd use a multiline string here:
return '''
# Gen
keertip
2013/01/31 22:40:41
Done.
|
| } |
| } |