cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject cordova-lib git commit: CB-9051 Plugins don't get re-added if platforms folder deleted.
Date Fri, 22 May 2015 01:15:06 GMT
Repository: cordova-lib
Updated Branches:
  refs/heads/master ae04a3ff7 -> bddcc8f2d


CB-9051 Plugins don't get re-added if platforms folder deleted.

To avoid attempting to add a plugin twice while adding a platform (a scenario that can occur
now with automatic restore of plugins and platforms), when adding plugins to a newly added
platform we check to see if the plugin has already been added by calling plugman's PlatformJson.isPluginInstalled(),
which looks in plugins/<platform>.json to see if the plugin has been installed for a
platform.

If you delete a platform's folder, it's plugins/<platform>.json file still exists, so
if you add the platform again, we think all plugins are already installed for it and so don't
try to install them.

Simple fix is to delete the platform's plugins/<platform>.json file before adding a
platform, so we start with a clean slate.


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

Branch: refs/heads/master
Commit: bddcc8f2d709a55df2d91c14def61212843a14e8
Parents: ae04a3f
Author: Tim Barham <tim.barham@microsoft.com>
Authored: Wed May 20 15:41:13 2015 -0700
Committer: Tim Barham <tim.barham@microsoft.com>
Committed: Thu May 21 18:08:19 2015 -0700

----------------------------------------------------------------------
 cordova-lib/src/cordova/platform.js | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/bddcc8f2/cordova-lib/src/cordova/platform.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/platform.js b/cordova-lib/src/cordova/platform.js
index 8bccbe1..7cc2b2d 100644
--- a/cordova-lib/src/cordova/platform.js
+++ b/cordova-lib/src/cordova/platform.js
@@ -122,6 +122,12 @@ function addHelper(cmd, hooksRunner, projectRoot, targets, opts) {
                         if (platformAlreadyAdded) {
                             throw new CordovaError('Platform ' + platform + ' already added.');
                         }
+
+                        // Remove the <platform>.json file from the plugins directory,
so we start clean (otherwise we
+                        // can get into trouble not installing plugins if someone deletes
the platform folder but
+                        // <platform>.json still exists).
+                        removePlatformPluginsJson(projectRoot, target);
+
                         var template_dir = config_json && config_json.lib &&
config_json.lib[platform] && config_json.lib[platform].template || null;
                         events.emit('log', 'Adding ' + platform + ' project...');
 
@@ -302,8 +308,7 @@ function remove(hooksRunner, projectRoot, targets, opts) {
     .then(function() {
         targets.forEach(function(target) {
             shell.rm('-rf', path.join(projectRoot, 'platforms', target));
-            var plugins_json = path.join(projectRoot, 'plugins', target + '.json');
-            if (fs.existsSync(plugins_json)) shell.rm(plugins_json);
+            removePlatformPluginsJson(projectRoot, target);
         });
     }).then(function() {
         var config_json = config.read(projectRoot);
@@ -663,6 +668,12 @@ function copy_cordovajs_src(projectRoot, platform, platLib) {
     } 
 }
 
+// Remove <platform>.json file from plugins directory.
+function removePlatformPluginsJson(projectRoot, target) {
+    var plugins_json = path.join(projectRoot, 'plugins', target + '.json');
+    shell.rm('-f', plugins_json);
+}
+
 module.exports.add = add;
 module.exports.remove = remove;
 module.exports.update = update;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message