Updated Branches: refs/heads/master 83bc35e32 -> f57dbd3d5
Revert "[CB-4714] Add -f option to 'plugin rm' to forcefully remove a plugin." This reverts commit c2461bc946555a3f43928d35ba1768c3cdcff03a. Didn't mean to check this in. Still has pending code review comments. Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/f57dbd3d Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/f57dbd3d Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/f57dbd3d Branch: refs/heads/master Commit: f57dbd3d5029c1906a12a73dd4a651ad1b1e4415 Parents: 83bc35e Author: Andrew Grieve <[email protected]> Authored: Wed Sep 4 14:36:50 2013 -0400 Committer: Andrew Grieve <[email protected]> Committed: Wed Sep 4 14:37:16 2013 -0400 ---------------------------------------------------------------------- src/uninstall.js | 28 ++++++++-------------------- src/util/dependencies.js | 10 ++-------- 2 files changed, 10 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/f57dbd3d/src/uninstall.js ---------------------------------------------------------------------- diff --git a/src/uninstall.js b/src/uninstall.js index f87ec20..c0cddf5 100644 --- a/src/uninstall.js +++ b/src/uninstall.js @@ -44,10 +44,8 @@ module.exports.uninstallPlatform = function(platform, project_dir, id, plugins_d module.exports.uninstallPlugin = function(id, plugins_dir, callback) { var plugin_dir = path.join(plugins_dir, id); - - // If already removed, skip. + // If already removed, skip. if (!fs.existsSync(plugin_dir)) { - // console.log("Skipped " + plugin_dir + " (not found)"); if (callback) callback(); return; } @@ -77,34 +75,24 @@ module.exports.uninstallPlugin = function(id, plugins_dir, callback) { // possible options: cli_variables, www_dir, is_top_level function runUninstall(actions, platform, project_dir, plugin_dir, plugins_dir, options, callback) { - var xml_path = path.join(plugin_dir, 'plugin.xml'); - if (!fs.existsSync(xml_path)) { - // log warning? - return; - } - - var plugin_et = xml_helpers.parseElementtreeSync(xml_path); + var xml_path = path.join(plugin_dir, 'plugin.xml') + , plugin_et = xml_helpers.parseElementtreeSync(xml_path); var plugin_id = plugin_et._root.attrib['id']; options = options || {}; - var dependency_info = dependencies.generate_dependency_info(plugins_dir, platform, 'remove'); + var dependency_info = dependencies.generate_dependency_info(plugins_dir, platform); var graph = dependency_info.graph; var dependents = graph.getChain(plugin_id); - var forced = options.cmd && (options.cmd.indexOf('-f') + options.cmd.indexOf('-force') > -2); var tlps = dependency_info.top_level_plugins; var diff_arr = []; tlps.forEach(function(tlp) { if (tlp != plugin_id) { var ds = graph.getChain(tlp); if (options.is_top_level && ds.indexOf(plugin_id) > -1) { - if(forced) { - require('../plugman').emit('log', tlp + ' depends on '+ plugin_id + ', but forcing removal...'); - } else { - var err = new Error('Another top-level plugin (' + tlp + ') relies on plugin ' + plugin_id + ', therefore aborting uninstallation.'); - if (callback) return callback(err); - else throw err; - } + var err = new Error('Another top-level plugin (' + tlp + ') relies on plugin ' + plugin_id + ', therefore aborting uninstallation.'); + if (callback) return callback(err); + else throw err; } diff_arr.push(ds); } @@ -183,7 +171,7 @@ function handleUninstall(actions, platform, plugin_id, plugin_et, project_dir, w // queue up the plugin so prepare can remove the config changes config_changes.add_uninstalled_plugin_to_prepare_queue(plugins_dir, path.basename(plugin_dir), platform, is_top_level); // call prepare after a successful uninstall - require('../plugman').prepare(project_dir, platform, plugins_dir); + require('./../plugman').prepare(project_dir, platform, plugins_dir); if (callback) callback(); } }); http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/f57dbd3d/src/util/dependencies.js ---------------------------------------------------------------------- diff --git a/src/util/dependencies.js b/src/util/dependencies.js index bf40eb1..32e07eb 100644 --- a/src/util/dependencies.js +++ b/src/util/dependencies.js @@ -1,11 +1,10 @@ var dep_graph = require('dep-graph'), path = require('path'), - fs = require('fs'), config_changes = require('./config-changes'), xml_helpers = require('./xml-helpers'); module.exports = { - generate_dependency_info:function(plugins_dir, platform, context) { + generate_dependency_info:function(plugins_dir, platform) { var json = config_changes.get_platform_json(plugins_dir, platform); var tlps = []; var graph = new dep_graph(); @@ -19,12 +18,7 @@ module.exports = { }); }); Object.keys(json.dependent_plugins).forEach(function(plug) { - var xmlPath = path.join(plugins_dir, plug, 'plugin.xml'); - if (context == 'remove' && !fs.existsSync(xmlPath)) { - return; // dependency may have been forcefully removed - } - - var xml = xml_helpers.parseElementtreeSync(xmlPath); + var xml = xml_helpers.parseElementtreeSync(path.join(plugins_dir, plug, 'plugin.xml')); var deps = xml.findall('dependency'); deps && deps.forEach(function(dep) { var id = dep.attrib.id;
