You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by br...@apache.org on 2013/09/05 17:39:42 UTC
git commit: [CB-4184]: Install plugins to platforms serially,
not in parallel.
Updated Branches:
refs/heads/master 16be5589e -> 1d6e3b318
[CB-4184]: Install plugins to platforms serially, not in parallel.
This prevents plugman stepping on itself while installing dependencies
across platforms.
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/1d6e3b31
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/1d6e3b31
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/1d6e3b31
Branch: refs/heads/master
Commit: 1d6e3b3181af6cbac00b0fe055759feb4f39258b
Parents: 16be558
Author: Braden Shepherdson <br...@gmail.com>
Authored: Thu Sep 5 11:38:21 2013 -0400
Committer: Braden Shepherdson <br...@gmail.com>
Committed: Thu Sep 5 11:38:21 2013 -0400
----------------------------------------------------------------------
spec/plugin.spec.js | 10 ++++++----
src/plugin.js | 20 ++++++++++++++------
2 files changed, 20 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/1d6e3b31/spec/plugin.spec.js
----------------------------------------------------------------------
diff --git a/spec/plugin.spec.js b/spec/plugin.spec.js
index f9c679a..5e021e2 100644
--- a/spec/plugin.spec.js
+++ b/spec/plugin.spec.js
@@ -27,7 +27,7 @@ var cordova = require('../cordova'),
platforms = require('../platforms');
var cwd = process.cwd();
-var supported_platforms = Object.keys(platforms).filter(function(p) { return p != 'www'; });
+var supported_platforms = Object.keys(platforms).filter(function(p) { return p != 'www'; }).sort();
var sample_plugins = ['one','two'];
var project_dir = path.join('some','path');
var plugins_dir = path.join(project_dir, 'plugins');
@@ -59,7 +59,9 @@ describe('plugin command', function() {
prep_spy = spyOn(cordova, 'prepare').andCallFake(function(t, cb) {
cb();
});
- plugman_install = spyOn(plugman, 'install');
+ plugman_install = spyOn(plugman, 'install').andCallFake(function(platform, platform_dir, plugin, plugins_dir, options, callback) {
+ callback();
+ });
plugman_fetch = spyOn(plugman, 'fetch').andCallFake(function(target, plugins_dir, opts, cb) { cb(false, path.join(plugins_dir, target)); });
plugman_search = spyOn(plugman, 'search').andCallFake(function(params, cb) { cb(); });
uninstallPlatform = spyOn(plugman.uninstall, 'uninstallPlatform');
@@ -132,14 +134,14 @@ describe('plugin command', function() {
cordova.plugin('add', sample_plugins);
sample_plugins.forEach(function(plug) {
supported_platforms.forEach(function(plat) {
- expect(plugman_install).toHaveBeenCalledWith((plat=='blackberry'?'blackberry10':plat), path.join(project_dir, 'platforms', plat), plug, plugins_dir, jasmine.any(Object));
+ expect(plugman_install).toHaveBeenCalledWith((plat=='blackberry'?'blackberry10':plat), path.join(project_dir, 'platforms', plat), plug, plugins_dir, jasmine.any(Object), jasmine.any(Function));
});
});
});
it('should pass down variables into plugman', function() {
cordova.plugin('add', "one", "--variable", "foo=bar");
supported_platforms.forEach(function(plat) {
- expect(plugman_install).toHaveBeenCalledWith((plat=='blackberry'?'blackberry10':plat), path.join(project_dir, 'platforms', plat), "one", plugins_dir, {www_dir: jasmine.any(String), cli_variables: { FOO: "bar"}});
+ expect(plugman_install).toHaveBeenCalledWith((plat=='blackberry'?'blackberry10':plat), path.join(project_dir, 'platforms', plat), "one", plugins_dir, {www_dir: jasmine.any(String), cli_variables: { FOO: "bar"}}, jasmine.any(Function));
});
});
it('should trigger callback without an error', function(done) {
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/1d6e3b31/src/plugin.js
----------------------------------------------------------------------
diff --git a/src/plugin.js b/src/plugin.js
index 842cdf2..8ea1b3e 100644
--- a/src/plugin.js
+++ b/src/plugin.js
@@ -121,9 +121,15 @@ module.exports = function plugin(command, targets, callback) {
if (callback) callback(err);
else throw err;
} else {
- // Iterate over all platforms in the project and install the plugin.
- platformList.forEach(function(platform) {
- var platformRoot = path.join(projectRoot, 'platforms', platform),
+ // Iterate (in serial!) over all platforms in the project and install the plugin.
+ var doInstall = function(platformIndex) {
+ if (platformIndex >= platformList.length) {
+ end();
+ return;
+ }
+
+ var platform = platformList[platformIndex],
+ platformRoot = path.join(projectRoot, 'platforms', platform),
parser = new platforms[platform].parser(platformRoot),
options = {
www_dir: parser.staging_dir(),
@@ -144,9 +150,11 @@ module.exports = function plugin(command, targets, callback) {
}
events.emit('log', 'Calling plugman.install on plugin "' + dir + '" for platform "' + platform + '" with options "' + JSON.stringify(options) + '"');
- plugman.install(platform, platformRoot, path.basename(dir), pluginsDir, options);
- });
- end();
+ plugman.install(platform, platformRoot, path.basename(dir), pluginsDir, options, function() {
+ doInstall(platformIndex+1);
+ });
+ };
+ doInstall(0);
}
});
});