Index: utils/pub/lock_file.dart |
diff --git a/utils/pub/lock_file.dart b/utils/pub/lock_file.dart |
index 8e7042330731cdf8cdfb6b3953a4af83112c39f7..a87903de701cfaf13d8fa6f83b795d064647fdf4 100644 |
--- a/utils/pub/lock_file.dart |
+++ b/utils/pub/lock_file.dart |
@@ -93,6 +93,34 @@ class LockFile { |
// 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}); |
+ // |
+ // (prujohn@gmail.com) remove the _stringifyPretty() wrapper once the |
+ // YAML impl ready. |
+ return _stringifyPretty(packagesObj); |
+ // return JSON.stringify({'packages' : packagesObj}); |
+ } |
+ |
+ /** |
+ * Provides a stringify on [packagesObj] to make the lock file more |
+ * human-readable. |
+ */ |
+ String _stringifyPretty(Map<String, Map> packagesObj){ |
+ final sb = new StringBuffer(); |
+ |
+ sb.add('packages:\n'); |
+ packagesObj.forEach((name, map){ |
+ sb.add(' ${name}:\n'); |
+ map.forEach((key, value){ |
+ if (key == "description" && value is Map){ |
+ sb.add(' description:\n'); |
+ value.forEach((dkey, dvalue){ |
+ sb.add(' ${dkey}: $dvalue\n'); |
+ }); |
+ }else{ |
+ sb.add(' ${key}: $value\n'); |
+ } |
+ }); |
+ }); |
+ return sb.toString(); |
} |
} |