Comparing version 1.3.2 to 1.3.3
@@ -16,3 +16,3 @@ /* wrench.js | ||
/* wrench.rmdirSyncRecursive("directory_path"); | ||
/* wrench.rmdirSyncRecursive("directory_path", forceDelete, failSilent); | ||
* | ||
@@ -23,18 +23,24 @@ * Recursively dives through directories and obliterates everything about it. This is a | ||
*/ | ||
exports.rmdirSyncRecursive = function(path) { | ||
var files = fs.readdirSync(path), | ||
currDir = path; | ||
exports.rmdirSyncRecursive = function(path, failSilent) { | ||
var files; | ||
try { | ||
files = fs.readdirSync(path); | ||
} catch (err) { | ||
if(failSilent) return; | ||
throw new Error(err.message); | ||
} | ||
/* 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]); | ||
} | ||
@@ -41,0 +47,0 @@ |
{ | ||
"name": "wrench", | ||
"description": "Recursive filesystem (and other) operations that Node *should* have.", | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"author": "Ryan McGrath <ryan@venodesigns.net>", | ||
@@ -6,0 +6,0 @@ |
@@ -26,3 +26,3 @@ wrench.js - Recursive file operations in Node.js | ||
// Recursively delete the entire sub-tree of a directory, then kill the directory | ||
wrench.rmdirSyncRecursive('my_directory_name'); | ||
wrench.rmdirSyncRecursive('my_directory_name', failSilently); | ||
@@ -29,0 +29,0 @@ // Recursively chmod the entire sub-tree of a directory |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
14142
259
0