cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [2/4] git commit: [CB-4077] Separate the actions of removing a plugin from a platform and removing the plugin entirely
Date Tue, 09 Jul 2013 21:10:55 GMT
[CB-4077] Separate the actions of removing a plugin from a platform and removing the plugin
entirely


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/05797d0c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/05797d0c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/05797d0c

Branch: refs/heads/CB-4077
Commit: 05797d0c7d4c801d1463445db0c37e0ae5d8a8af
Parents: f4ffadc
Author: Ian Clelland <iclelland@chromium.org>
Authored: Fri Jul 5 10:49:04 2013 -0400
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Tue Jul 9 12:41:29 2013 -0700

----------------------------------------------------------------------
 src/uninstall.js | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/05797d0c/src/uninstall.js
----------------------------------------------------------------------
diff --git a/src/uninstall.js b/src/uninstall.js
index dbe0fae..8728711 100644
--- a/src/uninstall.js
+++ b/src/uninstall.js
@@ -11,7 +11,17 @@ var path = require('path'),
     platform_modules = require('./platforms');
 
 // possible options: cli_variables, www_dir
-module.exports = function uninstallPlugin(platform, project_dir, id, plugins_dir, options,
callback) {
+module.exports = function(platform, project_dir, id, plugins_dir, options, callback) {
+    module.exports.uninstallPlatform(platform, project_dir, id, plugins_dir, options, function(err)
{
+        if (err) {
+            if (callback) return callback(err);
+            else throw err;
+        }
+        module.exports.uninstallPlugin(id, plugins_dir, options, callback);
+    });
+}
+
+module.exports.uninstallPlatform = function(platform, project_dir, id, plugins_dir, options,
callback) {
     if (!platform_modules[platform]) {
         var err = new Error(platform + " not supported.");
         if (callback) return callback(err);
@@ -32,11 +42,21 @@ module.exports = function uninstallPlugin(platform, project_dir, id, plugins_dir
     runUninstall(current_stack, platform, project_dir, plugin_dir, plugins_dir, options,
callback);
 };
 
+module.exports.uninstallPlugin = function(id, plugins_dir, callback) {
+    var plugin_dir = path.join(plugins_dir, id);
+    var xml_path     = path.join(plugin_dir, 'plugin.xml')
+      , plugin_et    = xml_helpers.parseElementtreeSync(xml_path);
+    var plugin_id    = plugin_et._root.attrib['id'];
+    // axe the directory
+    shell.rm('-rf', plugin_dir);
+    require('../plugman').emit('log', plugin_id + ' uninstalled.');
+    if (callback) 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')
       , plugin_et    = xml_helpers.parseElementtreeSync(xml_path);
-    var name         = plugin_et.findall('name').text;
     var plugin_id    = plugin_et._root.attrib['id'];
     options = options || {};
 
@@ -131,9 +151,6 @@ function handleUninstall(actions, platform, plugin_id, plugin_et, project_dir,
w
             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);
-            require('../plugman').emit('log', plugin_id + ' uninstalled.');
             if (callback) callback();
         }
     });


Mime
View raw message