fs-multi
extends fs-extra v9.0.0
for working multiple files.
npm install fs-multi
fs-multi
is a drop in replacement for fs-extra v9.0.0
. All methods in fs
and fs-extra
are attached to fs-multi
.
You don't ever need to include the native fs
or fs-extra
modules. You can now include only fs-multi
module.
const fs = require('fs-multi')
copy
or move
multiple files or directories.
method
<string>
Methods may becopy
ormove
.files
<Object>
Destinations, options and callback functions or<string>
as only destinations for each file. Each key of<Object>
is referred tosrc
(see:copy
ormove
).
Working with multiple files:
const fs = require('fs-multi')
let files = {
// dest is in <Object>
'/tmp/myfile': {
dest: '/tmp/mynewfile',
callback: err => {
if (err) console.error(err)
else console.log('myfile success!')
}
},
// dest is <string> itself
'/tmp/mysecondfile': '/tmp/mysecondnewfile'
}
fs.multi('copy', files).then(
() => console.log('multiple processes completed'))
.catch(err => console.error(err)
)
Working with native fs
and fs-extra
methods:
fs.copy('/tmp/mydir', '/tmp/mynewdir') //fs-extra 'copy' method
fs.copyFile('/tmp/myfile', '/tmp/mynewfile') //fs 'copyFile' method
Licensed under MIT