cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [1/2] git commit: Support web-only plugins with no config changes
Date Tue, 12 Mar 2013 23:24:52 GMT
Support web-only plugins with no config changes

The lack of a <plugin> line on Android and BB10, and lack of
config_changes on iOS, was causing installation failures.


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

Branch: refs/heads/master
Commit: 5198005e624d652c9a49a1c411401ea6cc6fa550
Parents: c5f4335
Author: Braden Shepherdson <braden@chromium.org>
Authored: Wed Feb 13 14:58:34 2013 -0500
Committer: Braden Shepherdson <braden.shepherdson@gmail.com>
Committed: Tue Mar 12 11:17:40 2013 -0400

----------------------------------------------------------------------
 platforms/android.js |    8 +++++++-
 platforms/bb10.js    |    5 ++++-
 platforms/ios.js     |   18 ++++++++++--------
 3 files changed, 21 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/5198005e/platforms/android.js
----------------------------------------------------------------------
diff --git a/platforms/android.js b/platforms/android.js
index 590f82e..892f7b0 100644
--- a/platforms/android.js
+++ b/platforms/android.js
@@ -201,7 +201,13 @@ function androidPackageName(project_dir) {
 
 function pluginInstalled(plugin_et, project_dir, config_xml_filename) {
     var tag_xpath = util.format('./platform[@name="android"]/config-file[@target="%s"]/plugin',
config_xml_filename);
-    var plugin_name = plugin_et.find(tag_xpath).attrib.name;
+
+    var plugin_tag = plugin_et.find(tag_xpath);
+    if (!plugin_tag) {
+        return false;
+    }
+    var plugin_name = plugin_tag.attrib.name;
+
     return (fs.readFileSync(path.resolve(project_dir, config_xml_filename), 'utf8')
            .match(new RegExp(plugin_name, "g")) != null);
 }

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/5198005e/platforms/bb10.js
----------------------------------------------------------------------
diff --git a/platforms/bb10.js b/platforms/bb10.js
index fbbd5b5..5d3f649 100644
--- a/platforms/bb10.js
+++ b/platforms/bb10.js
@@ -166,7 +166,10 @@ function srcPath(pluginPath, filename) {
 }
 
 function pluginInstalled(plugin_et, project_dir) {
-    var config_tag = plugin_et.find('./platform[@name="BlackBerry10"]/config-file[@target="config.xml"]/feature')
+    var config_tag = plugin_et.find('./platform[@name="BlackBerry10"]/config-file[@target="config.xml"]/feature');
+    if (!config_tag) {
+        return false;
+    }
     var plugin_name = config_tag.attrib.id;
     return (fs.readFileSync(path.resolve(project_dir, 'config.xml'), 'utf8')
            .match(new RegExp(plugin_name, "g")) != null);

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/5198005e/platforms/ios.js
----------------------------------------------------------------------
diff --git a/platforms/ios.js b/platforms/ios.js
index c5f4b7b..b0cec42 100644
--- a/platforms/ios.js
+++ b/platforms/ios.js
@@ -75,7 +75,7 @@ exports.handlePlugin = function (action, project_dir, plugin_dir, plugin_et)
{
         frameworks = platformTag.findall('./framework');
 
     // move asset files into www
-    assets.forEach(function (asset) {
+    assets && assets.forEach(function (asset) {
         var srcPath = path.resolve(
                         plugin_dir, asset.attrib['src']);
 
@@ -94,7 +94,7 @@ exports.handlePlugin = function (action, project_dir, plugin_dir, plugin_et)
{
     });
 
     // move native files (source/header/resource)
-    sourceFiles.forEach(function (sourceFile) {
+    sourceFiles && sourceFiles.forEach(function (sourceFile) {
         var src = sourceFile.attrib['src'],
             srcFile = path.resolve(plugin_dir, 'src/ios', src),
             targetDir = path.resolve(pluginsDir, getRelativeDir(sourceFile)),
@@ -112,7 +112,7 @@ exports.handlePlugin = function (action, project_dir, plugin_dir, plugin_et)
{
         }
     });
 
-    headerFiles.forEach(function (headerFile) {
+    headerFiles && headerFiles.forEach(function (headerFile) {
         var src = headerFile.attrib['src'],
             srcFile = path.resolve(plugin_dir, 'src/ios', src),
             targetDir = path.resolve(pluginsDir, getRelativeDir(headerFile)),
@@ -130,7 +130,7 @@ exports.handlePlugin = function (action, project_dir, plugin_dir, plugin_et)
{
         }
     });
 
-    resourceFiles.forEach(function (resource) {
+    resourceFiles && resourceFiles.forEach(function (resource) {
         var src = resource.attrib['src'],
             srcFile = path.resolve(plugin_dir, 'src/ios', src),
             destFile = path.resolve(resourcesDir, path.basename(src));
@@ -149,7 +149,7 @@ exports.handlePlugin = function (action, project_dir, plugin_dir, plugin_et)
{
         }
     });
 
-    frameworks.forEach(function (framework) {
+    frameworks && frameworks.forEach(function (framework) {
         var src = framework.attrib['src'],
             weak = framework.attrib['weak'];
 
@@ -203,7 +203,7 @@ function updatePlistFile(action, config_path, plugin_et) {
     
     if (action == 'install') {
         // add hosts to whitelist (ExternalHosts) in plist
-        hosts.forEach(function(host) {
+        hosts && hosts.forEach(function(host) {
             plistObj.ExternalHosts.push(host.attrib['origin']);
         });
 
@@ -215,7 +215,7 @@ function updatePlistFile(action, config_path, plugin_et) {
         // it's not an entry added by this plugin 
         for(i=0; i < plistObj.ExternalHosts.length;i++) {
             matched = false;
-            hosts.forEach(function(host) {
+            hosts && hosts.forEach(function(host) {
                 if(host === plistObj.ExternalHosts[i]) {
                     matched = true;
                 }
@@ -238,6 +238,9 @@ function updatePlistFile(action, config_path, plugin_et) {
 function pluginInstalled(plugin_et, config_path) {
     var config_tag = plugin_et.find('./platform[@name="ios"]/config-file[@target="config.xml"]/plugin')
||
                      plugin_et.find('./platform[@name="ios"]/plugins-plist');
+    if (!config_tag) {
+        return false;
+    }
     var plugin_name = config_tag.attrib.name || config_tag.attrib.key;
     return (fs.readFileSync(config_path, 'utf8').match(new RegExp(plugin_name, "g")) != null);
 }
@@ -274,7 +277,6 @@ function updateConfigXml(action, config_path, plugin_et) {
             var culprit = pluginsEl.find("plugin[@name='"+name+"']");
             pluginsEl.remove(0, culprit);
         }
-
     }
 
 	// add whitelist hosts


Mime
View raw message