@alexbinary/cp
v1.0.1
Published
Simple file/directory copy with promise support 🎉
Downloads
34
Maintainers
Readme
cp
Simple file/directory copy with promise support 🎉
Uses @alexbinary/promisify and @alexbinary/callbackify by alexbinary
Install
$ npm install @alexbinary/cp
# or
$ yarn add @alexbinary/cp
Usage
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
})
Documentation
let cp = require('@alexbinary/cp')
cp(source, target)
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.
cp.sync(source, target)
Synchronous version.
Licence
MIT