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

Unified Diff: utils/pub/lock_file.dart

Issue 12133002: add a comment to the generated lock file (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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/tests/pub/lock_file_test.dart » ('j') | utils/tests/pub/lock_file_test.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
}
}
« no previous file with comments | « no previous file | utils/tests/pub/lock_file_test.dart » ('j') | utils/tests/pub/lock_file_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698