Skip to content

Commit

Permalink
8x faster copy
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Jun 4, 2020
1 parent c807887 commit 5da37ca
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions tasks/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,17 @@ module.exports = function(grunt) {
tally.dirs++;
} else {
grunt.verbose.writeln('Copying ' + chalk.cyan(src) + ' -> ' + chalk.cyan(dest));
grunt.file.copy(src, dest, copyOptions);
if (options.timestamp !== false) {
syncTimestamp(src, dest);
}
if (options.mode !== false) {
fs.chmodSync(dest, (options.mode === true) ? fs.lstatSync(src).mode : options.mode);
// use 8x faster copy if possible.
if (fs.copyFileSync && options.mode !== false && options.timestamp !== false && !options.process) {
fs.copyFileSync(src, dest);
} else {
grunt.file.copy(src, dest, copyOptions);
if (options.timestamp !== false) {
syncTimestamp(src, dest);
}
if (options.mode !== false) {
fs.chmodSync(dest, (options.mode === true) ? fs.lstatSync(src).mode : options.mode);
}
}
tally.files++;
}
Expand Down

0 comments on commit 5da37ca

Please sign in to comment.