package
Copy a file
npm install cp-fileGitHub-flavored package documentation.
Across all versions, last 30 days.
7,447,250 in 30 days
Runtime metadata.
Tagged topics.
Copy a file
fs.copyFileSync() in the synchronous version.npm install cp-fileimport {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 => {
// …
}
});Estimated unpacked size across 6 packages.
106.3 kB
Includes dependencies.
^2.0.0
5.1.0
^4.1.2
4.2.12
^5.0.1
5.2.1
^2.0.0
2.1.1