A promise based simplified Node.js directory copy recursive API that also returns the list of files and directories.
There are so many great packages out there based on the Node.js file system. However, recently I felt that there's nothing very simple but offers asyncrhonus operation in Node.js file system for copying directories.
In addition, I have always wanted to publish packages in NPM. This package just let me starts my journey with NPM and GitHub package registry. I also learned a lot on how the GitHub Actions works.
This package is currently available on both NPM and GitHub package registry. You can either install it from NPM or GitHub package registry like the followings:
Install from the command line:
npm install @mazik/fs-easy-dir-copy@latest
The package @mazik/fs-easy-dir-copy()
accepts two arguments. The first argument is a string of source path and the second argument is also a string of destination path.
You will need to import the package as you'd normally do with any other NPM package like the following:
const copyDirectory = require('@mazik/fs-easy-dir-copy')
You'll need to use the copyDirectory
using asynchronously:
const copyDirectory = require('@mazik/fs-easy-dir-copy');
copyDirectory('./sourcePath', './destinationPath').then(items => {
console.log(items);
}).catch(error => {
console.log(error);
})
Based on your source path, the items
variable will return an array of objects like the following:
[
{ name: 'another', directory: true },
{ name: 'readme.md', directory: false },
{ name: 'test.md', directory: false },
]
- "node": ">=13.11.0"
You'll need to simply run the following:
yarn test
This project is licensed under the MIT License - see the LICENSE file for details