You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by br...@apache.org on 2013/08/13 16:22:45 UTC

git commit: plugin rm now doesn't choke when a file is already deleted

Updated Branches:
  refs/heads/master 0d1815ed0 -> 0c0e0949d


plugin rm now doesn't choke when a file is already deleted


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

Branch: refs/heads/master
Commit: 0c0e0949dbf4ee202dab70579c7af17aba8b7576
Parents: 0d1815e
Author: Braden Shepherdson <br...@gmail.com>
Authored: Tue Aug 13 10:11:40 2013 -0400
Committer: Braden Shepherdson <br...@gmail.com>
Committed: Tue Aug 13 10:21:44 2013 -0400

----------------------------------------------------------------------
 src/platforms/common.js | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/0c0e0949/src/platforms/common.js
----------------------------------------------------------------------
diff --git a/src/platforms/common.js b/src/platforms/common.js
index 0e602c1..684690b 100644
--- a/src/platforms/common.js
+++ b/src/platforms/common.js
@@ -41,20 +41,23 @@ module.exports = {
     },
     // Sometimes we want to remove some java, and prune any unnecessary empty directories
     deleteJava:function(project_dir, destFile) {
-        fs.unlinkSync(path.resolve(project_dir,destFile));
+        var file = path.resolve(project_dir, destFile);
+        if (!fs.existsSync(file)) return;
+
+        module.exports.removeFileF(file);
+
         // check if directory is empty
+        var curDir = path.dirname(file);
 
-        var curDir = path.resolve(project_dir, path.dirname(destFile));
         while(curDir !== path.resolve(project_dir, 'src')) {
-            //console.log('curDir ' + curDir);
-            if(fs.readdirSync(curDir).length == 0) {
+            if(fs.existsSync(curDir) && fs.readdirSync(curDir) == 0) {
                 fs.rmdirSync(curDir);
                 curDir = path.resolve(curDir, '..');
             } else {
                 // directory not empty...do nothing
                 break;
             }
-        }   
+        }
     },
     // handle <asset> elements
     asset:{