Merge pull request #75 from gdw2/master
Added "preserveTimestamps" option
This commit is contained in:
commit
1b4ef049c4
2 changed files with 5 additions and 0 deletions
|
|
@ -252,6 +252,7 @@ exports.copyDirSyncRecursive = function(sourceDir, newDirLocation, opts) {
|
||||||
var files = fs.readdirSync(sourceDir);
|
var files = fs.readdirSync(sourceDir);
|
||||||
var hasFilter = opts.filter || opts.include || opts.exclude;
|
var hasFilter = opts.filter || opts.include || opts.exclude;
|
||||||
var preserveFiles = opts.preserveFiles === true;
|
var preserveFiles = opts.preserveFiles === true;
|
||||||
|
var preserveTimestamps = opts.preserveTimestamps === true;
|
||||||
|
|
||||||
for(var i = 0; i < files.length; i++) {
|
for(var i = 0; i < files.length; i++) {
|
||||||
// ignores all files or directories which match the RegExp in opts.filter
|
// ignores all files or directories which match the RegExp in opts.filter
|
||||||
|
|
@ -274,6 +275,9 @@ exports.copyDirSyncRecursive = function(sourceDir, newDirLocation, opts) {
|
||||||
fs.writeFileSync(destFile, contents);
|
fs.writeFileSync(destFile, contents);
|
||||||
var stat = fs.lstatSync(srcFile);
|
var stat = fs.lstatSync(srcFile);
|
||||||
fs.chmodSync(destFile, stat.mode);
|
fs.chmodSync(destFile, stat.mode);
|
||||||
|
if (preserveTimestamps) {
|
||||||
|
fs.utimesSync(destFile, stat.atime, stat.mtime)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if(currFile.isDirectory()) {
|
if(currFile.isDirectory()) {
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,7 @@ wrench.copyDirSyncRecursive('directory_to_copy', 'location_where_copy_should_end
|
||||||
forceDelete: bool, // Whether to overwrite existing directory or not
|
forceDelete: bool, // Whether to overwrite existing directory or not
|
||||||
excludeHiddenUnix: bool, // Whether to copy hidden Unix files or not (preceding .)
|
excludeHiddenUnix: bool, // Whether to copy hidden Unix files or not (preceding .)
|
||||||
preserveFiles: bool, // If we're overwriting something and the file already exists, keep the existing
|
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
|
inflateSymlinks: bool, // Whether to follow symlinks or not when copying files
|
||||||
filter: regexpOrFunction, // A filter to match files against; if matches, do nothing (exclude).
|
filter: regexpOrFunction, // A filter to match files against; if matches, do nothing (exclude).
|
||||||
whitelist: bool, // if true every file or directory which doesn't match filter will be ignored
|
whitelist: bool, // if true every file or directory which doesn't match filter will be ignored
|
||||||
|
|
|
||||||
Reference in a new issue