You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2013/05/16 17:57:12 UTC
[13/20] git commit: uninstallation with dependents should now work.
uninstallation with dependents should now work.
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/e05e51ac
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/e05e51ac
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/e05e51ac
Branch: refs/heads/master
Commit: e05e51acbbd149a2e4288436e923690486491a4d
Parents: be96c19
Author: Fil Maj <ma...@gmail.com>
Authored: Tue May 14 23:50:43 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu May 16 08:55:42 2013 -0700
----------------------------------------------------------------------
src/install.js | 5 +++--
src/uninstall.js | 34 ++++++++++++++++++++--------------
2 files changed, 23 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/e05e51ac/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index 24f012d..37a6dff 100644
--- a/src/install.js
+++ b/src/install.js
@@ -146,8 +146,8 @@ function handleInstall(plugin_id, plugin_et, platform, project_dir, plugins_dir,
// run through the action stack
action_stack.process(platform, project_dir, function(err) {
if (err) {
- console.error(err.message, err.stack);
- console.error('Plugin installation failed :(');
+ if (callback) callback(err);
+ else throw err;
} else {
// WIN!
// Log out plugin INFO element contents in case additional install steps are necessary
@@ -161,6 +161,7 @@ function handleInstall(plugin_id, plugin_et, platform, project_dir, plugins_dir,
// call prepare after a successful install
require('./../plugman').prepare(project_dir, platform, plugins_dir);
+ console.log(plugin_id + ' installed.');
if (callback) callback();
}
});
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/e05e51ac/src/uninstall.js
----------------------------------------------------------------------
diff --git a/src/uninstall.js b/src/uninstall.js
index ee0cd62..986e7c1 100644
--- a/src/uninstall.js
+++ b/src/uninstall.js
@@ -1,8 +1,10 @@
var path = require('path'),
fs = require('fs'),
et = require('elementtree'),
+ shell= require('shelljs'),
config_changes = require('./util/config-changes'),
action_stack = require('./util/action-stack'),
+ n = require('ncallbacks'),
dependencies = require('./util/dependencies'),
underscore = require('underscore'),
platform_modules = require('./platforms');
@@ -44,26 +46,27 @@ function runUninstall(platform, project_dir, plugin_dir, plugins_dir, cli_variab
if (tlp != plugin_id) {
var ds = graph.getChain(tlp);
if (is_top_level && ds.indexOf(plugin_id) > -1) {
- // Another top-level plugin depends on this one
- // Cannot uninstall then.
- console.log('Another top-level plugin (' + tlp + ') relies on plugin ' + plugin_id + ', therefore, aborting uninstallation.');
- if (callback) callback();
+ var err = new Error('Another top-level plugin (' + tlp + ') relies on plugin ' + plugin_id + ', therefore aborting uninstallation.');
+ if (callback) callback(err);
+ else throw err;
return;
}
diff_arr.push(ds);
}
});
- if (dependents.length) {
- // this plugin has dependencies
- diff_arr.unshift(dependents);
- // do a set difference to determine which dependencies are not required by other existing plugins
- var danglers = underscore.difference.apply(null, diff_arr);
- danglers && danglers.forEach(function(dangle) {
- // TODO: fire off an uninstall for each danglin' dep
+ // if this plugin has dependencies, do a set difference to determine which dependencies are not required by other existing plugins
+ diff_arr.unshift(dependents);
+ var danglers = underscore.difference.apply(null, diff_arr);
+ if (dependents.length && danglers && danglers.length) {
+ var end = n(danglers.length, function() {
+ handleUninstall(platform, plugin_id, plugin_et, project_dir, www_dir, plugins_dir, plugin_dir, is_top_level, callback);
+ });
+ danglers.forEach(function(dangler) {
+ module.exports(platform, project_dir, dangler, plugins_dir, cli_variables, www_dir, false /* TODO: should this "is_top_level" param be false for dependents? */, end);
});
} else {
- // this plugin is bare, uninstall it!
+ // this plugin can get axed by itself, gogo!
handleUninstall(platform, plugin_id, plugin_et, project_dir, www_dir, plugins_dir, plugin_dir, is_top_level, callback);
}
}
@@ -109,14 +112,17 @@ function handleUninstall(platform, plugin_id, plugin_et, project_dir, www_dir, p
// run through the action stack
action_stack.process(platform, project_dir, function(err) {
if (err) {
- console.error(err.message, err.stack);
- console.error('Plugin uninstallation failed :(');
+ if (callback) callback(err);
+ else throw err;
} else {
// WIN!
// 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);
+ // axe the directory
+ shell.rm('-rf', plugin_dir);
+ console.log(plugin_id + ' uninstalled.');
if (callback) callback();
}
});