You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by go...@apache.org on 2013/10/08 03:11:35 UTC

git commit: [CB-5012]: No whitespace in empty plist string nodes.

Updated Branches:
  refs/heads/CB-5012 [created] ecadd1b8f


[CB-5012]: No whitespace in empty plist string nodes.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/ecadd1b8
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/ecadd1b8
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/ecadd1b8

Branch: refs/heads/CB-5012
Commit: ecadd1b8f0f729edc10bfc5ec77708f5dd18e9a0
Parents: f240acc
Author: Brett Rudd <br...@gmail.com>
Authored: Mon Oct 7 18:07:52 2013 -0700
Committer: Brett Rudd <br...@gmail.com>
Committed: Mon Oct 7 18:07:52 2013 -0700

----------------------------------------------------------------------
 spec/plugins/VariablePlugin/plugin.xml |  3 +++
 spec/util/config-changes.spec.js       | 10 ++++++++++
 src/util/config-changes.js             |  3 ++-
 3 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/ecadd1b8/spec/plugins/VariablePlugin/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/plugins/VariablePlugin/plugin.xml b/spec/plugins/VariablePlugin/plugin.xml
index b713bed..2b63d52 100644
--- a/spec/plugins/VariablePlugin/plugin.xml
+++ b/spec/plugins/VariablePlugin/plugin.xml
@@ -43,5 +43,8 @@
             <awesome value="$API_KEY" />
             <cfbundleid>$PACKAGE_NAME</cfbundleid>
         </config-file>
+        <config-file target="*-Info.plist" parent="APluginNode">
+            <string></string>
+        </config-file>
     </platform>
 </plugin>

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/ecadd1b8/spec/util/config-changes.spec.js
----------------------------------------------------------------------
diff --git a/spec/util/config-changes.spec.js b/spec/util/config-changes.spec.js
index ea6ecd0..1a088c0 100644
--- a/spec/util/config-changes.spec.js
+++ b/spec/util/config-changes.spec.js
@@ -281,6 +281,16 @@ describe('config-changes module', function() {
                     expect(spy).not.toHaveBeenCalledWith(path.join(temp, 'res', 'xml', 'plugins.xml'), 'utf-8');
                 });
             });
+            describe('of plist config files', function() {
+                var xcode_add, xcode_rm;
+                it('should write empty string nodes with no whitespace', function() {
+                    shell.cp('-rf', ios_config_xml, temp);
+                    shell.cp('-rf', varplugin, plugins_dir);
+                    configChanges.add_installed_plugin_to_prepare_queue(plugins_dir, 'VariablePlugin', 'ios', {});
+                    configChanges.process(plugins_dir, temp, 'ios');
+                    expect(fs.readFileSync(path.join(temp, 'SampleApp', 'SampleApp-Info.plist'), 'utf-8')).toMatch(/<key>APluginNode<\/key>\n    <string><\/string>/m);
+                });
+            });
             describe('of pbxproject framework files', function() {
                 var xcode_add, xcode_rm;
                 beforeEach(function() {

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/ecadd1b8/src/util/config-changes.js
----------------------------------------------------------------------
diff --git a/src/util/config-changes.js b/src/util/config-changes.js
index 7ebd8b8..351efa3 100644
--- a/src/util/config-changes.js
+++ b/src/util/config-changes.js
@@ -379,7 +379,8 @@ module.exports = {
                                         // TODO: could parse the filepath once per unique target instead of on every change
                                         var plistObj = pl.parseFileSync(filepath);
                                         if (plist_helpers.graftPLIST(plistObj, xml_child, selector)) {
-                                            fs.writeFileSync(filepath, plist.build(plistObj));
+                                            var regExp = new RegExp("<string>[ \t\r\n]+?</string>", "g");
+                                            fs.writeFileSync(filepath, plist.build(plistObj).replace(regExp, "<string></string>"));
                                         } else {
                                             throw new Error('grafting to plist "' + filepath + '" during config install went bad :(');
                                         }