Comparing version 1.2.0 to 1.3.0
@@ -11,4 +11,2 @@ /* wrench.js | ||
* | ||
* These are all developed due to my work on Luno (http://github.com/ryanmcgrath/luno). | ||
* | ||
* ~ Ryan McGrath (ryan [at] venodesigns.net) | ||
@@ -117,3 +115,30 @@ */ | ||
/* wrench.chownSyncRecursive("directory", uid, gid); | ||
* | ||
* Recursively dives through a directory and chowns everything to the desired user and group. This is a | ||
* Synchronous function, which blocks things until it's done. | ||
* | ||
* Note: Directories should be passed to this function without a trailing slash. | ||
*/ | ||
exports.chownSyncRecursive = function(sourceDir, uid, gid) { | ||
var files = fs.readdirSync(sourceDir); | ||
for(var i = 0; i < files.length; i++) { | ||
var currFile = fs.statSync(sourceDir + "/" + files[i]); | ||
if(currFile.isDirectory()) { | ||
/* ...and recursion this thing right on back. */ | ||
exports.chownSyncRecursive(sourceDir + "/" + files[i], uid, gid); | ||
} else { | ||
/* At this point, we've hit a file actually worth chowning... so own it. */ | ||
fs.chownSync(sourceDir + "/" + files[i], uid, gid); | ||
} | ||
} | ||
/* Finally, chown the parent directory */ | ||
fs.chownSync(sourceDir, uid, gid); | ||
}; | ||
/* wrench.rmdirRecursive("directory_path", callback); | ||
@@ -120,0 +145,0 @@ * |
{ | ||
"name": "wrench", | ||
"description": "Recursive filesystem (and other) operations that Node *should* have.", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"author": "Ryan McGrath <ryan@venodesigns.net>", | ||
@@ -6,0 +6,0 @@ |
@@ -19,3 +19,3 @@ wrench.js - Recursive file operations in Node.js | ||
``` javascript | ||
var wrench = require('./wrench'), | ||
var wrench = require('wrench'), | ||
util = require('util'); | ||
@@ -29,2 +29,5 @@ | ||
// Recursively chown the entire sub-tree of a directory | ||
wrench.chownSyncRecursive("directory", uid, gid); | ||
// Deep-copy an existing directory | ||
@@ -31,0 +34,0 @@ wrench.copyDirSyncRecursive('directory_to_copy', 'location_where_copy_should_end_up'); |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
12688
211
43
0