Node.js v8.5.0 fs.copyFileSync ponyfill.
Synchronously copies src to dest. By default, dest is overwritten if it already exists. Returns undefined. Node.js makes no guarantees about the atomicity of the copy operation. If an error occurs after the destination file has been opened for writing, Node.js will attempt to remove the destination.
npm i fs-copy-file-sync-sync
flags is an optional integer that specifies the behavior of the copy operation. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g.
fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE).
fs.constants.COPYFILE_EXCL- The copy operation will fail if dest already exists.
fs.constants.COPYFILE_FICLONE- The copy operation will attempt to create a copy-on-write reflink. If the platform does not support copy-on-write, then a fallback copy mechanism is used.
fs.constants.COPYFILE_FICLONE_FORCE- The copy operation will attempt to create a copy-on-write reflink. If the platform does not support copy-on-write, then the operation will fail.
const copyFileSync = ;// destination.txt will be created or overwritten by default.;console;
If the third argument is a number, then it specifies flags, as shown in the following example.
const copyFileSync = ;const COPYFILE_EXCL = copyFileSyncconstants;// By using COPYFILE_EXCL, the operation will fail if destination.txt exists.fs;
- fs-copy-file - Asynchronously copies src to dest.