1.1.0 • Published 4 years ago
recursivedircopy v1.1.0
Recursive Dir Copy
Asynchronous recursive copying file and directories. Work on Promises. Behavior is similar to cp -r
Installation
npm i recursivedircopyUsage
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 = 0mean that recursion will not stop until all directories and files will be copied. Default:0options.filter<Function>is a function that run for every file/dir inSOURCE, have 1 argument - the name of file or directory. Returntrueto copy file/dir,falseto ignore. Also can returnPromisethat resolvetrue/false. Default:undefinedoptions.force<Boolean>overwrite dirs/files inDESTINATIONthat already exists iftrue. Default:falseoptions.errorOnExist<Boolean>throw error if try to overwrite dirs/files inDESTINATIONthat already exists and ifoptions.force=false. Default:false