You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2015/09/14 16:45:25 UTC
cordova-lib git commit: CB-9617 Do not restore plugins after plugin
removal.
Repository: cordova-lib
Updated Branches:
refs/heads/master d104e3939 -> 6666136f7
CB-9617 Do not restore plugins after plugin removal.
This closes #304
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/6666136f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/6666136f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/6666136f
Branch: refs/heads/master
Commit: 6666136f7a98c4327f4331d3055cb88de7c6df15
Parents: d104e39
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Wed Sep 9 18:25:10 2015 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Mon Sep 14 17:45:13 2015 +0300
----------------------------------------------------------------------
cordova-lib/src/cordova/plugin.js | 11 +++---
cordova-lib/src/cordova/prepare.js | 68 ++++++++++++++++++++-------------
2 files changed, 47 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/6666136f/cordova-lib/src/cordova/plugin.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/plugin.js b/cordova-lib/src/cordova/plugin.js
index d2a44b4..cc9aafc 100644
--- a/cordova-lib/src/cordova/plugin.js
+++ b/cordova-lib/src/cordova/plugin.js
@@ -31,8 +31,7 @@ var cordova_util = require('./util'),
pluginMapper = require('cordova-registry-mapper').newToOld,
events = require('../events'),
metadata = require('../plugman/util/metadata'),
- chainMap = require('../util/promise-util').Q_chainmap,
- cordova = require('./cordova');
+ chainMap = require('../util/promise-util').Q_chainmap;
// Returns a promise.
module.exports = function plugin(command, targets, opts) {
@@ -200,7 +199,9 @@ module.exports = function plugin(command, targets, opts) {
});
}, Q()); // end Q.all
}).then(function() {
- return cordova.raw.prepare(opts);
+ // Need to require right here instead of doing this at the beginning of file
+ // otherwise tests are failing without any real reason.
+ return require('./prepare').preparePlatforms(platformList, projectRoot, opts);
}).then(function() {
opts.cordova = { plugins: cordova_util.findPlugins(pluginPath) };
return hooksRunner.fire('after_plugin_add', opts);
@@ -228,7 +229,7 @@ module.exports = function plugin(command, targets, opts) {
return platformList.reduce(function(soFar, platform) {
return soFar.then(function() {
var platformRoot = path.join(projectRoot, 'platforms', platform);
- events.emit('verbose', 'Calling plugman.uninstall on plugin "' + target + '" for platform "' + platform + '"');
+ events.emit('verbose', 'Calling plugman.uninstall on plugin "' + target + '" for platform "' + platform + '"');
return plugman.raw.uninstall.uninstallPlatform(platform, platformRoot, target, pluginPath);
});
}, Q())
@@ -254,7 +255,7 @@ module.exports = function plugin(command, targets, opts) {
});
}, Q());
}).then(function () {
- return cordova.raw.prepare(opts);
+ return require('./prepare').preparePlatforms(platformList, projectRoot, opts);
}).then(function() {
opts.cordova = { plugins: cordova_util.findPlugins(pluginPath) };
return hooksRunner.fire('after_plugin_rm', opts);
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/6666136f/cordova-lib/src/cordova/prepare.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/prepare.js b/cordova-lib/src/cordova/prepare.js
index 16750c3..b8a8ad4 100644
--- a/cordova-lib/src/cordova/prepare.js
+++ b/cordova-lib/src/cordova/prepare.js
@@ -51,33 +51,7 @@ function prepare(options) {
options = cordova_util.preProcessOptions(options);
options.searchpath = options.searchpath || config_json.plugin_search_path;
// Iterate over each added platform
- return Q.all(options.platforms.map(function(platform) {
- // TODO: this need to be replaced by real projectInfo
- // instance for current project.
- var project = {
- root: projectRoot,
- projectConfig: new ConfigParser(cordova_util.projectConfig(projectRoot)),
- locations: {
- plugins: path.join(projectRoot, 'plugins'),
- www: cordova_util.projectWww(projectRoot)
- }
- };
-
- // platformApi prepare takes care of all functionality
- // which previously had been executed by cordova.prepare:
- // - reset config.xml and then merge changes from project's one,
- // - update www directory from project's one and merge assets from platform_www,
- // - reapply config changes, made by plugins,
- // - update platform's project
- // Please note that plugins' changes, such as installes js files, assets and
- // config changes is not being reinstalled on each prepare.
- var platformApi = platforms.getPlatformApi(platform);
- return platformApi.prepare(project)
- .then(function () {
- if (options.browserify)
- return browserify(project, platformApi);
- });
- }));
+ return preparePlatforms(options.platforms, projectRoot, options);
}).then(function() {
options.paths = options.platforms.map(function(platform) {
return platforms.getPlatformApi(platform).getPlatformInfo().locations.www;
@@ -87,3 +61,43 @@ function prepare(options) {
return restore.installPluginsFromConfigXML(options);
});
}
+
+/**
+ * Calls `platformApi.prepare` for each platform in project
+ *
+ * @param {string[]} platformList List of platforms, added to current project
+ * @param {string} projectRoot Project root directory
+ *
+ * @return {Promise}
+ */
+function preparePlatforms (platformList, projectRoot, options) {
+ return Q.all(platformList.map(function(platform) {
+ // TODO: this need to be replaced by real projectInfo
+ // instance for current project.
+ var project = {
+ root: projectRoot,
+ projectConfig: new ConfigParser(cordova_util.projectConfig(projectRoot)),
+ locations: {
+ plugins: path.join(projectRoot, 'plugins'),
+ www: cordova_util.projectWww(projectRoot)
+ }
+ };
+
+ // platformApi prepare takes care of all functionality
+ // which previously had been executed by cordova.prepare:
+ // - reset config.xml and then merge changes from project's one,
+ // - update www directory from project's one and merge assets from platform_www,
+ // - reapply config changes, made by plugins,
+ // - update platform's project
+ // Please note that plugins' changes, such as installes js files, assets and
+ // config changes is not being reinstalled on each prepare.
+ var platformApi = platforms.getPlatformApi(platform);
+ return platformApi.prepare(project)
+ .then(function () {
+ if (options.browserify)
+ return browserify(project, platformApi);
+ });
+ }));
+}
+
+module.exports.preparePlatforms = preparePlatforms;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org