You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2015/04/23 22:58:41 UTC
cordova-plugins git commit: CB-8901 - Improve install/uninstall hooks
to workaround elementtree remove bug
Repository: cordova-plugins
Updated Branches:
refs/heads/master 3206f7362 -> a0f8c5a1c
CB-8901 - Improve install/uninstall hooks to workaround elementtree remove bug
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugins/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugins/commit/a0f8c5a1
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugins/tree/a0f8c5a1
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugins/diff/a0f8c5a1
Branch: refs/heads/master
Commit: a0f8c5a1c9e4c02092af19490641b866c77563c9
Parents: 3206f73
Author: Shazron Abdullah <sh...@apache.org>
Authored: Thu Apr 23 13:58:38 2015 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Thu Apr 23 13:58:38 2015 -0700
----------------------------------------------------------------------
local-webserver/scripts/after_install.js | 9 +++++++--
local-webserver/scripts/before_uninstall.js | 13 ++++++++-----
2 files changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/a0f8c5a1/local-webserver/scripts/after_install.js
----------------------------------------------------------------------
diff --git a/local-webserver/scripts/after_install.js b/local-webserver/scripts/after_install.js
index b728bf3..d138091 100644
--- a/local-webserver/scripts/after_install.js
+++ b/local-webserver/scripts/after_install.js
@@ -44,8 +44,13 @@ module.exports = function(context) {
content_tags[0].set('src', content_src_value);
}
- var pref = et.Element('preference', { name: 'AlternateContentSrc', value: old_content_src_value });
- etree.getroot().append(pref);
+ var altcontentsrcTag = etree.findall("./preference[@name='AlternateContentSrc']");
+ if (altcontentsrcTag.length > 0) {
+ altcontentsrcTag[0].set('value', old_content_src_value);
+ } else {
+ var pref = et.Element('preference', { name: 'AlternateContentSrc', value: old_content_src_value });
+ etree.getroot().append(pref);
+ }
data = etree.write({'indent': 4});
fs.writeFileSync(config_xml, data);
http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/a0f8c5a1/local-webserver/scripts/before_uninstall.js
----------------------------------------------------------------------
diff --git a/local-webserver/scripts/before_uninstall.js b/local-webserver/scripts/before_uninstall.js
index e455a59..f0fbe92 100644
--- a/local-webserver/scripts/before_uninstall.js
+++ b/local-webserver/scripts/before_uninstall.js
@@ -45,11 +45,14 @@ module.exports = function(context) {
content_tags[0].set('src', backup_data.content_src);
}
}
- // There is a bug in remove :(
- // var altcontentsrcTag = etree.findall("./preference[@name='AlternateContentSrc']");
- // if (altcontentsrcTag.length > 0) {
- // etree.getroot().remove(altcontentsrcTag[0]);
- // }
+ // There is a bug in elementtree remove :(
+ var altcontentsrcTag = etree.findall("./preference[@name='AlternateContentSrc']");
+ if (altcontentsrcTag.length > 0) {
+ try {
+ etree.getroot().remove(altcontentsrcTag[0]);
+ } catch (e) {
+ }
+ }
data = etree.write({'indent': 4});
fs.writeFileSync(config_xml, data);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org