Security News
Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
fs-copy-file
Advanced tools
Readme
Node.js v8.5.0 fs.copyFile ponyfill.
Asynchronously copies src
to dest
. By default, dest is overwritten if it already exists. No arguments other than a possible exception are given to the callback function. 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.
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.npm i fs-copy-file
Create pipe between streams and adds callback wich would be called once whenever everything is done, or error occures.
const copyFile = require('fs-copy-file');
// destination.txt will be created or overwritten by default.
copyFile('source.txt', 'destination.txt', (err) => {
if (err)
throw err;
console.log('source.txt was copied to destination.txt');
});
If the third argument is a number, then it specifies flags, as shown in the following example.
const copyFile = require('fs-copy-file');
const { COPYFILE_EXCL } = copyFile.constants;
// By using COPYFILE_EXCL, the operation will fail if destination.txt exists.
fs.copyFile('source.txt', 'destination.txt', COPYFILE_EXCL, callback);
MIT
FAQs
fs.copyFile ponyfill
The npm package fs-copy-file receives a total of 20,674 weekly downloads. As such, fs-copy-file popularity was classified as popular.
We found that fs-copy-file demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.