recursivedircopy
v1.1.0
Published
Asynchronous recursive file and directories copying with Promise support
Downloads
8
Readme
Recursive Dir Copy
Asynchronous recursive copying file and directories. Work on Promises. Behavior is similar to cp -r
Installation
npm i recursivedircopy
Usage
copy(SOURCE, DESTINATION[, OPTIONS])
const copy = require('recursive-dir-copy');
copy(SOURCE, DESTINATION)
.then(() => {
console.log('Successfully copied');
})
.catch((err) => {
console.error(err);
});
OR
try {
const copy = require('recursive-dir-copy');
await copy(SOURCE, DESTINATION);
console.log('Successfully copied');
} catch(err) {
console.error(err);
}
Options
options.limit<Number>
is a maximum recursion depth.options.limit = 0
mean that recursion will not stop until all directories and files will be copied. Default:0
options.filter<Function>
is a function that run for every file/dir inSOURCE
, have 1 argument - the name of file or directory. Returntrue
to copy file/dir,false
to ignore. Also can returnPromise
that resolvetrue
/false
. Default:undefined
options.force<Boolean>
overwrite dirs/files inDESTINATION
that already exists iftrue
. Default:false
options.errorOnExist<Boolean>
throw error if try to overwrite dirs/files inDESTINATION
that already exists and ifoptions.force=false
. Default:false