cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject git commit: uninstallation with dependents should now work.
Date Wed, 15 May 2013 06:50:50 GMT
Updated Branches:
  refs/heads/dependencies ef1dd3acc -> b77a05710


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/b77a0571
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/b77a0571
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/b77a0571

Branch: refs/heads/dependencies
Commit: b77a0571022b3f1f4d29c1a66e59c5c000df7df9
Parents: ef1dd3a
Author: Fil Maj <maj.fil@gmail.com>
Authored: Tue May 14 23:50:43 2013 -0700
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Tue May 14 23:50:43 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/b77a0571/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index f3829d6..a65de7e 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/b77a0571/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();
         }
     });


Mime
View raw message