CB-10328 set top-level property when adding new platforms This closes #402
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/114de6cd Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/114de6cd Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/114de6cd Branch: refs/heads/common-1.1.x Commit: 114de6cd532e2218c1b302ae61bf8e3f50ec749d Parents: 618eeca Author: Byoungro So <byoungro...@intel.com> Authored: Fri Mar 4 18:51:43 2016 -0800 Committer: Vladimir Kotikov <v-vlk...@microsoft.com> Committed: Sat Mar 5 14:50:39 2016 +0300 ---------------------------------------------------------------------- cordova-lib/spec-cordova/platform.spec.js | 47 ++++++++++++++++++++++++++ cordova-lib/src/cordova/platform.js | 8 +++-- cordova-lib/src/plugman/install.js | 3 +- 3 files changed, 54 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/114de6cd/cordova-lib/spec-cordova/platform.spec.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-cordova/platform.spec.js b/cordova-lib/spec-cordova/platform.spec.js index 2c99b4a..a35216f 100644 --- a/cordova-lib/spec-cordova/platform.spec.js +++ b/cordova-lib/spec-cordova/platform.spec.js @@ -201,3 +201,50 @@ describe('add function', function () { }); }); }); + +describe('platform add plugin rm end-to-end', function () { + + var tmpDir = helpers.tmpDir('plugin_rm_test'); + var project = path.join(tmpDir, 'hello'); + var pluginsDir = path.join(project, 'plugins'); + + beforeEach(function() { + process.chdir(tmpDir); + }); + + afterEach(function() { + process.chdir(path.join(__dirname, '..')); // Needed to rm the dir on Windows. + shell.rm('-rf', tmpDir); + }); + + it('should remove dependency when removing parent plugin', function(done) { + + cordova.raw.create('hello') + .then(function() { + process.chdir(project); + return cordova.raw.platform('add', 'ios'); + }) + .then(function() { + return cordova.raw.plugin('add', 'cordova-plugin-media'); + }) + .then(function() { + expect(path.join(pluginsDir, 'cordova-plugin-media')).toExist(); + expect(path.join(pluginsDir, 'cordova-plugin-file')).toExist(); + return cordova.raw.platform('add', 'android'); + }) + .then(function() { + expect(path.join(pluginsDir, 'cordova-plugin-media')).toExist(); + expect(path.join(pluginsDir, 'cordova-plugin-file')).toExist(); + return cordova.raw.plugin('rm', 'cordova-plugin-media'); + }) + .then(function() { + expect(path.join(pluginsDir, 'cordova-plugin-media')).not.toExist(); + expect(path.join(pluginsDir, 'cordova-plugin-file')).not.toExist(); + }) + .fail(function(err) { + console.error(err); + expect(err).toBeUndefined(); + }) + .fin(done); + }, 20000); +}); http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/114de6cd/cordova-lib/src/cordova/platform.js ---------------------------------------------------------------------- diff --git a/cordova-lib/src/cordova/platform.js b/cordova-lib/src/cordova/platform.js index 2dff594..d130772 100644 --- a/cordova-lib/src/cordova/platform.js +++ b/cordova-lib/src/cordova/platform.js @@ -644,6 +644,9 @@ function installPluginsForNewPlatform(platform, projectRoot, opts) { events.emit('verbose', 'Installing plugin "' + plugin + '" following successful platform add of ' + platform); plugin = path.basename(plugin); + // Get plugin variables from fetch.json if have any and pass them as cli_variables to plugman + var pluginMetadata = fetchMetadata.get_fetch_metadata(path.join(plugins_dir, plugin)); + var options = { searchpath: opts.searchpath, // Set up platform to install asset files/js modules to <platform>/platform_www dir @@ -654,11 +657,10 @@ function installPluginsForNewPlatform(platform, projectRoot, opts) { // NOTE: there is another code path for plugin installation (see CB-10274 and the // related PR: https://github.com/apache/cordova-lib/pull/360) so we need to // specify the option below in both places - usePlatformWww: true + usePlatformWww: true, + is_top_level: pluginMetadata.is_top_level }; - // Get plugin variables from fetch.json if have any and pass them as cli_variables to plugman - var pluginMetadata = fetchMetadata.get_fetch_metadata(path.join(plugins_dir, plugin)); var variables = pluginMetadata && pluginMetadata.variables; if (variables) { events.emit('verbose', 'Found variables for "' + plugin + '". Processing as cli_variables.'); http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/114de6cd/cordova-lib/src/plugman/install.js ---------------------------------------------------------------------- diff --git a/cordova-lib/src/plugman/install.js b/cordova-lib/src/plugman/install.js index a7e793f..c0a12c1 100644 --- a/cordova-lib/src/plugman/install.js +++ b/cordova-lib/src/plugman/install.js @@ -71,7 +71,8 @@ module.exports = function installPlugin(platform, project_dir, id, plugins_dir, project_dir = cordovaUtil.convertToRealPathSafe(project_dir); plugins_dir = cordovaUtil.convertToRealPathSafe(plugins_dir); options = options || {}; - options.is_top_level = true; + if (!options.hasOwnProperty('is_top_level')) options.is_top_level = true; + plugins_dir = plugins_dir || path.join(project_dir, 'cordova', 'plugins'); if (!platform_modules[platform]) { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org