cp-file
Advanced tools
Weekly downloads
Readme
Copy a file
fs.copyFileSync()
in the synchronous version.npm install cp-file
import {copyFile} from 'cp-file';
await copyFile('source/unicorn.png', 'destination/unicorn.png');
console.log('File copied');
Returns a Promise
that resolves when the file is copied.
Type: string
The file you want to copy.
Type: string
Where you want the file copied.
Type: object
Type: boolean
Default: true
Overwrite existing destination file.
Type: string
Default: process.cwd()
The working directory to find source files.
The source and destination path are relative to this.
Type: number
Default: 0o777
Permissions for created directories.
It has no effect on Windows.
Type: (progress: ProgressData) => void
The given function is called whenever there is measurable progress.
Only available when using the async method.
ProgressData
{
sourcePath: string,
destinationPath: string,
size: number,
writtenBytes: number,
percent: number
}
sourcePath
and destinationPath
are absolute paths.size
and writtenBytes
are in bytes.percent
is a value between 0
and 1
.onProgress
callback function is emitted only once.import {copyFile} from 'cp-file';
await copyFile(source, destination, {
onProgress: progress => {
// …
}
});
FAQs
Copy a file
The npm package cp-file receives a total of 2,777,696 weekly downloads. As such, cp-file popularity was classified as popular.
We found that cp-file demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.