You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bh...@apache.org on 2014/09/29 21:49:21 UTC

git commit: CB-5390 Uninstall - recursively remove dependencies of dependencies

Repository: cordova-lib
Updated Branches:
  refs/heads/master e48f4877e -> 9ca23557a


CB-5390 Uninstall - recursively remove dependencies of dependencies


Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/9ca23557
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/9ca23557
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/9ca23557

Branch: refs/heads/master
Commit: 9ca23557af9543a3c97ef08f282d4d9f8efe9575
Parents: e48f487
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Mon Sep 29 14:03:51 2014 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Mon Sep 29 15:49:03 2014 -0400

----------------------------------------------------------------------
 cordova-lib/src/plugman/uninstall.js | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/9ca23557/cordova-lib/src/plugman/uninstall.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/uninstall.js b/cordova-lib/src/plugman/uninstall.js
index 82db79d..b74596f 100644
--- a/cordova-lib/src/plugman/uninstall.js
+++ b/cordova-lib/src/plugman/uninstall.js
@@ -117,11 +117,19 @@ module.exports.uninstallPlugin = function(id, plugins_dir, options) {
     var top_plugin_id = id;
 
     // Recursively remove plugins which were installed as dependents (that are not top-level)
-    // optional?
-    var recursive = true;
-    var toDelete = recursive ? plugin_et.findall('.//dependency') : [];
-    toDelete = toDelete && toDelete.length ? toDelete.map(function(p) { return p.attrib.id; }) : [];
+    var toDelete = [];
     toDelete.push(top_plugin_id);
+    function findDependencies(pluginId) {
+        var config = xml_helpers.parseElementtreeSync(path.join(plugin_dir, '..', pluginId, 'plugin.xml')),
+            deps = config.findall('.//dependency').map(function (p) { return p.attrib.id; });
+        deps.forEach(function (d) {
+            if (toDelete.indexOf(d) === -1) {
+                toDelete.push(d);
+                findDependencies(d);
+            }
+        });
+    }
+    findDependencies(top_plugin_id);
 
     // Okay, now we check if any of these are depended on, or top-level.
     // Find the installed platforms by whether they have a metadata file.