diff --git a/lib/wrench.js b/lib/wrench.js index 6e47f6a..a9227b1 100644 --- a/lib/wrench.js +++ b/lib/wrench.js @@ -20,7 +20,7 @@ var fs = require("fs"); * Asynchronous version. :\ */ exports.rmdirSyncRecursive = function(path, failSilent) { - var files, currDir = path; + var files; try { files = fs.readdirSync(path); } catch (err) { if (failSilent) return; @@ -29,16 +29,16 @@ exports.rmdirSyncRecursive = function(path, failSilent) { /* Loop through and delete everything in the sub-tree after checking it */ for(var i = 0; i < files.length; i++) { - var currFile = fs.statSync(currDir + "/" + files[i]); + var currFile = fs.statSync(path + "/" + files[i]); if(currFile.isDirectory()) // Recursive function back to the beginning - exports.rmdirSyncRecursive(currDir + "/" + files[i]); + exports.rmdirSyncRecursive(path + "/" + files[i]); else if(currFile.isSymbolicLink()) // Unlink symlinks - fs.unlinkSync(currDir + "/" + files[i]); + fs.unlinkSync(path + "/" + files[i]); else // Assume it's a file - perhaps a try/catch belongs here? - fs.unlinkSync(currDir + "/" + files[i]); + fs.unlinkSync(path + "/" + files[i]); } /* Now that we know everything in the sub-tree has been deleted, we can delete the main