I am able to copy a file in node.js using the following:
var readStream = fs.createReadStream(fromFilePath);
readStream.pipe(fs.createWriteStream(toFilePath));
The question is how to also copy/keep the modified time (mtime) like in a regular file copy command.
There are methods in the fs
module to access mtime:
var stat = fs.statSync(fromFilePath);
fs.utimesSync(toFilePath, stat.atime, stat.mtime)