Output indented XML.

Currently elementtree would compress the entire XML structure onto a
single line when saving a file. This makes any further hand-editing
close to impossible.

This change causes elementtree to output XML with a 4-space indent
keeping it human-friendly.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/commit/20924a4d
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/tree/20924a4d
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/diff/20924a4d

Branch: refs/heads/cordova-client
Commit: 20924a4d2c7a7c87ee571ef9efe448126ac9b719
Parents: ed8721f
Author: Darryl Pogue <dvpdin...@gmail.com>
Authored: Fri Sep 21 22:49:11 2012 -0700
Committer: Darryl Pogue <dvpdin...@gmail.com>
Committed: Fri Sep 21 22:49:11 2012 -0700

----------------------------------------------------------------------
 package.json                   |    2 +-
 src/build.js                   |    2 +-
 src/config_parser.js           |    2 +-
 src/metadata/android_parser.js |    2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/20924a4d/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index eb34477..6d46f3d 100644
--- a/package.json
+++ b/package.json
@@ -22,7 +22,7 @@
   "dependencies": {
     "colors":">=0.6.0",
     "wrench":"1.3.9",
-    "elementtree":"0.1.1",
+    "elementtree":"0.1.3",
     "pluginstall":"git://github.com/imhotep/pluginstall.git",
     "node-xcode":"git://github.com/imhotep/node-xcode.git",
     "express":"3.0",

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/20924a4d/src/build.js
----------------------------------------------------------------------
diff --git a/src/build.js b/src/build.js
index d2e0d88..7f0ade1 100644
--- a/src/build.js
+++ b/src/build.js
@@ -41,7 +41,7 @@ module.exports = function build (callback) {
                     var stringsXml = path.join(projectRoot, 'platforms', 
'android', 'res', 'values', 'strings.xml');
                     var strings = new 
et.ElementTree(et.XML(fs.readFileSync(stringsXml, 'utf-8')));
                     strings.find('string[@name="app_name"]').text = name;
-                    fs.writeFileSync(stringsXml, strings.write(), 'utf-8');
+                    fs.writeFileSync(stringsXml, strings.write({indent: 4}), 
'utf-8');
                     break;
                 case 'ios':
                     assetsPath = path.join(projectRoot, 'platforms', 'ios', 
'www');

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/20924a4d/src/config_parser.js
----------------------------------------------------------------------
diff --git a/src/config_parser.js b/src/config_parser.js
index 9060fe4..aa743dc 100644
--- a/src/config_parser.js
+++ b/src/config_parser.js
@@ -44,7 +44,7 @@ config_parser.prototype = {
         } else return this.doc.find('name').text;
     },
     update:function() {
-        fs.writeFileSync(this.path, this.doc.write(), 'utf-8');
+        fs.writeFileSync(this.path, this.doc.write({indent: 4}), 'utf-8');
     }
 };
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/20924a4d/src/metadata/android_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/android_parser.js b/src/metadata/android_parser.js
index edb58c9..48d2880 100644
--- a/src/metadata/android_parser.js
+++ b/src/metadata/android_parser.js
@@ -19,6 +19,6 @@ module.exports.prototype = {
         var name = config.name();
         var strings = new et.ElementTree(et.XML(fs.readFileSync(this.strings, 
'utf-8')));
         strings.find('string[@name="app_name"]').text = name;
-        fs.writeFileSync(this.strings, strings.write(), 'utf-8');
+        fs.writeFileSync(this.strings, strings.write({indent: 4}), 'utf-8');
     }
 };

Reply via email to