Simple file/directory copy with promise support ๐
Uses @alexbinary/promisify and @alexbinary/callbackify by alexbinary
$ npm install @alexbinary/cp
# or
$ yarn add @alexbinary/cp
let cp = require('@alexbinary/cp')
// copy a file
cp('/source/foo.txt', '/target/foo.txt').then(() => {
// file /source/foo.txt is copied under /target/foo.txt
// folder /target is created if it does not exist
})
// copy a folder
cp('/source/folder', '/target/folder').then(() => {
// folder /source/folder is copied with all its content under /target/folder
// folder /target is created if it does not exist
})
let cp = require('@alexbinary/cp')
Copies file or directory from source
to target
.
If source
is a directory then it is copied with all its content.
Intermediate directories are created if necessary.
This method supports both Promise and node callback style, and resolves with no arguments.
Synchronous version.
MIT