You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2015/03/27 15:29:28 UTC

cordova-lib git commit: CB-8651 Restoring platforms causes plugin install to be triggered twice (close #196)

Repository: cordova-lib
Updated Branches:
  refs/heads/master 318c46003 -> e6c940d2a


CB-8651 Restoring platforms causes plugin install to be triggered twice  (close #196)

If you add a platform and there are plugins listed in config.xml, those plugins get added twice. One during prepare(), when we add all plugins listed in config.xml, and once in platform.add(), when we add all installed plugins to the new platform.

Both these cases are needed in different scenarios, so the easiest fix seemed to be to check for and ignore plugins that have already been installed for a platform, in installPluginsForNewPlatform().


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

Branch: refs/heads/master
Commit: e6c940d2adc501e08ca6e7a1a969191c2daef4df
Parents: 318c460
Author: Tim Barham <ti...@microsoft.com>
Authored: Fri Mar 27 23:45:15 2015 +1000
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Mar 27 10:27:02 2015 -0400

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


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/e6c940d2/cordova-lib/src/cordova/platform.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/platform.js b/cordova-lib/src/cordova/platform.js
index d94de38..16761c5 100644
--- a/cordova-lib/src/cordova/platform.js
+++ b/cordova-lib/src/cordova/platform.js
@@ -36,6 +36,7 @@ var config            = require('./config'),
     unorm             = require('unorm'),
     shell             = require('shelljs'),
     _                 = require('underscore'),
+    PlatformJson      = require('../plugman/util/PlatformJson'),
     platformMetadata  = require('./platform_metadata');
 
 // Expose the platform parsers on top of this command
@@ -589,12 +590,20 @@ function getCreateArgs(platDetails, projectRoot, cfg, template_dir, opts) {
 }
 
 function installPluginsForNewPlatform(platform, projectRoot, cfg, opts) {
-    var output = path.join(projectRoot, 'platforms', platform);
     // Install all currently installed plugins into this new platform.
     var plugins_dir = path.join(projectRoot, 'plugins');
-    var plugins = cordova_util.findPlugins(plugins_dir);
-    if (!plugins) return Q();
 
+    // Get a list of all currently installed plugins, ignoring those that have already been installed for this platform
+    // during prepare (installed from config.xml).
+    var platformJson = PlatformJson.load(plugins_dir, platform);
+    var plugins = cordova_util.findPlugins(plugins_dir).filter(function (plugin) {
+        return !platformJson.isPluginInstalled(plugin);
+    });
+    if (plugins.length === 0) {
+        return Q();
+    }
+
+    var output = path.join(projectRoot, 'platforms', platform);
     var plugman = require('../plugman/plugman');
     // Install them serially.
     return plugins.reduce(function(soFar, plugin) {


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