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

Unified Diff: sdk/lib/_internal/pub/lib/src/lock_file.dart

Issue 15777002: Use indentation for maps in lockfile. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 7 years, 7 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
Index: sdk/lib/_internal/pub/lib/src/lock_file.dart
diff --git a/sdk/lib/_internal/pub/lib/src/lock_file.dart b/sdk/lib/_internal/pub/lib/src/lock_file.dart
index 316e8b58803b9b72e6421b8804c8ac146849b79e..7f69ca1ce098ab41e509bc99f1eaeb3e8743d48c 100644
--- a/sdk/lib/_internal/pub/lib/src/lock_file.dart
+++ b/sdk/lib/_internal/pub/lib/src/lock_file.dart
@@ -4,12 +4,12 @@
library lock_file;
-import 'dart:json' as json;
import 'dart:collection';
import 'package:yaml/yaml.dart';
import 'io.dart';
+import 'log.dart' as log;
import 'package.dart';
import 'source_registry.dart';
import 'utils.dart';
@@ -88,25 +88,20 @@ class LockFile {
/// Returns the serialized YAML text of the lock file.
String serialize() {
- var packagesObj = new LinkedHashMap<String, Map>();
-
- // Sort the packages by name.
- var sortedKeys = packages.keys.toList();
- sortedKeys.sort();
- sortedKeys.forEach((name) {
- packagesObj[name] = {
+ // Convert the dependencies to a simple object.
+ var data = {};
+ packages.forEach((name, package) {
+ data[name] = {
'version': packages[name].version.toString(),
'source': packages[name].source,
'description': packages[name].description
};
});
- // 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
- '# Generated by pub\n'
- '# See http://pub.dartlang.org/doc/glossary.html#lockfile\n'
- '\n'
- '${json.stringify({'packages': packagesObj})}\n';
+ return """
+# Generated by pub
+# See http://pub.dartlang.org/doc/glossary.html#lockfile
+${yamlToString({'packages': data})}
+""";
}
}
« no previous file with comments | « no previous file | sdk/lib/_internal/pub/lib/src/solver/version_solver.dart » ('j') | sdk/lib/_internal/pub/lib/src/utils.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698