Comparing version 1.5.6 to 1.5.7
@@ -255,2 +255,3 @@ /* wrench.js | ||
var preserveFiles = opts.preserveFiles === true; | ||
var preserveTimestamps = opts.preserveTimestamps === true; | ||
@@ -278,2 +279,5 @@ for(var i = 0; i < files.length; i++) { | ||
fs.chmodSync(destFile, stat.mode); | ||
if (preserveTimestamps) { | ||
fs.utimesSync(destFile, stat.atime, stat.mtime) | ||
} | ||
}; | ||
@@ -286,2 +290,3 @@ | ||
var symlinkFull = fs.readlinkSync(_path.join(sourceDir, files[i])); | ||
symlinkFull = _path.resolve(fs.realpathSync(sourceDir), symlinkFull); | ||
@@ -293,8 +298,8 @@ if (typeof opts !== 'undefined' && !opts.inflateSymlinks) { | ||
var tmpCurrFile = fs.lstatSync(_path.join(sourceDir, symlinkFull)); | ||
var tmpCurrFile = fs.lstatSync(symlinkFull); | ||
if (tmpCurrFile.isDirectory()) { | ||
exports.copyDirSyncRecursive(_path.join(sourceDir, symlinkFull), _path.join(newDirLocation, files[i]), opts); | ||
exports.copyDirSyncRecursive(symlinkFull, _path.join(newDirLocation, files[i]), opts); | ||
} else { | ||
/* At this point, we've hit a file actually worth copying... so copy it on over. */ | ||
fCopyFile(_path.join(sourceDir, symlinkFull), _path.join(newDirLocation, files[i])); | ||
fCopyFile(symlinkFull, _path.join(newDirLocation, files[i])); | ||
} | ||
@@ -439,6 +444,8 @@ } else { | ||
fs.stat(file, function(err, fileStat){ | ||
if (err) return clbk(err); | ||
if (fileStat.isDirectory()) | ||
copyDirRecursive(file, newFile, copyFiles); | ||
copyDirRecursive(file, newFile, copyFiles, clbk); | ||
else if (fileStat.isSymbolicLink()) | ||
fs.readlink(file, function(err, link){ | ||
if (err) return clbk(err); | ||
fs.symlink(link, newFile, copyFiles); | ||
@@ -448,2 +455,3 @@ }); | ||
fs.readFile(file, function(err, data){ | ||
if (err) return clbk(err); | ||
fs.writeFile(newFile, data, copyFiles); | ||
@@ -450,0 +458,0 @@ }); |
{ | ||
"name": "wrench", | ||
"description": "Recursive filesystem (and other) operations that Node *should* have.", | ||
"version": "1.5.6", | ||
"version": "1.5.7", | ||
"author": "Ryan McGrath <ryan@venodesigns.net>", | ||
@@ -6,0 +6,0 @@ |
@@ -68,2 +68,3 @@ wrench.js - Recursive file operations in Node.js | ||
preserveFiles: bool, // If we're overwriting something and the file already exists, keep the existing | ||
preserveTimestamps: bool, // Preserve the mtime and atime when copying files | ||
inflateSymlinks: bool, // Whether to follow symlinks or not when copying files | ||
@@ -70,0 +71,0 @@ filter: regexpOrFunction, // A filter to match files against; if matches, do nothing (exclude). |
@@ -49,2 +49,17 @@ var testCase = require('nodeunit').testCase; | ||
function checkResultInflateAbsolute(test, files) { | ||
var check = [ | ||
'.hidden', | ||
'absolute-bar.txt', | ||
'bar.txt', | ||
'test', | ||
path.join('.hidden', 'dolor.md') | ||
]; | ||
test.deepEqual(files, check); | ||
test.deepEqual(fs.lstatSync(path.join(__dirname, 'testdir/.hidden')).isSymbolicLink(), false); | ||
test.deepEqual(fs.lstatSync(path.join(__dirname, 'testdir/bar.txt')).isSymbolicLink(), false); | ||
} | ||
function checkResultDontInflate(test, files) { | ||
@@ -96,3 +111,2 @@ var check = [ | ||
wrench.mkdirSyncRecursive(testdir, 0777); | ||
wrench.copyDirSyncRecursive(dir, testdir, { excludeHiddenUnix: false }); | ||
@@ -114,3 +128,2 @@ | ||
wrench.mkdirSyncRecursive(testdir, 0777); | ||
wrench.copyDirSyncRecursive(dir, testdir, { excludeHiddenUnix: true }); | ||
@@ -132,3 +145,2 @@ | ||
wrench.mkdirSyncRecursive(testdir, 0777); | ||
wrench.copyDirSyncRecursive(dir, testdir, { excludeHiddenUnix: false, inflateSymlinks: true }); | ||
@@ -144,2 +156,23 @@ | ||
}, | ||
test_copyDirSyncRecursiveInflateAbsoluteSymlinks: function(test) { | ||
var dir = path.join(__dirname, 'withsymlinks'); | ||
var testdir = path.join(__dirname, 'testdir'); | ||
fs.symlinkSync( | ||
path.resolve(__dirname, 'shown/bar.txt'), | ||
path.join(dir, 'absolute-bar.txt') | ||
); | ||
wrench.mkdirSyncRecursive(testdir, 0777); | ||
wrench.copyDirSyncRecursive(dir, testdir, { forceDelete: true, excludeHiddenUnix: false, inflateSymlinks: true }); | ||
var files = wrench.readdirSyncRecursive(testdir); | ||
checkResultInflateAbsolute(test, files); | ||
wrench.rmdirSyncRecursive(testdir); | ||
fs.unlinkSync(path.join(dir, 'absolute-bar.txt')); | ||
test.done(); | ||
}, | ||
test_copyDirSyncRecursiveDontInflate: function(test) { | ||
@@ -151,3 +184,2 @@ var dir = path.join(__dirname, 'withsymlinks'); | ||
wrench.mkdirSyncRecursive(testdir, 0777); | ||
wrench.copyDirSyncRecursive(dir, testdir, { excludeHiddenUnix: false, inflateSymlinks: false }); | ||
@@ -170,3 +202,3 @@ | ||
wrench.mkdirSyncRecursive(testdir1, 0777); | ||
// wrench.mkdirSyncRecursive(testdir1, 0777); | ||
wrench.copyDirSyncRecursive(dir, testdir1, { excludeHiddenUnix: false }); | ||
@@ -178,3 +210,3 @@ wrench.copyDirSyncRecursive(dir, testdir2, { excludeHiddenUnix: false }); | ||
wrench.copyDirSyncRecursive(testdir1, testdir2, { preserve: true, excludeHiddenUnix: false, preserveFiles: true }); | ||
wrench.copyDirSyncRecursive(testdir1, testdir2, { excludeHiddenUnix: false, preserveFiles: true }); | ||
@@ -197,3 +229,3 @@ var files = wrench.readdirSyncRecursive(testdir2); | ||
wrench.mkdirSyncRecursive(testdir1, 0777); | ||
// wrench.mkdirSyncRecursive(testdir1, 0777); | ||
wrench.copyDirSyncRecursive(dir, testdir1, { excludeHiddenUnix: false }); | ||
@@ -205,3 +237,3 @@ wrench.copyDirSyncRecursive(dir, testdir2, { excludeHiddenUnix: false }); | ||
wrench.copyDirSyncRecursive(testdir1, testdir2, { preserve: true, excludeHiddenUnix: false, preserveFiles: false }); | ||
wrench.copyDirSyncRecursive(testdir1, testdir2, { forceDelete: true, excludeHiddenUnix: false, preserveFiles: false }); | ||
@@ -208,0 +240,0 @@ var files = wrench.readdirSyncRecursive(testdir2); |
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
37540
743
104