1.0.0 • Published 6 years ago
fs-multi v1.0.0
Node.js: fs-multi
fs-multi extends fs-extra v9.0.0 for working multiple files.
Installation
npm install fs-multiUsage
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')multi(method, files)
copy or move multiple files or directories.
method<string>Methods may becopyormove.files<Object>Destinations, options and callback functions or<string>as only destinations for each file. Each key of<Object>is referred tosrc(see:copyormove).
Example:
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' methodLicense
Licensed under MIT