njfs
v1.2.5
Published
A small collection of sync & async filesystem functions in Node.js.
Downloads
3,022
Maintainers
Readme
Node Js File System
A small collection of sync & async filesystem functions for Node Js.
Install
npm install --save-dev njfs
Methods
- unix(path): Synchronous. Returns path with unix-like directory separators.
- root(path): Synchronous. Returns the root directory of the package.
- list(path, opts): Asynchronous. Returns the list of files and folders of the given path.
- move(path, dest): Asynchronous. Moves files or folders.
- copy(path, dest): Asynchronous. Copies files or folders.
- isFile(path): Synchronous. Checks whether the specified path is an existing file or not.
- isDir(path): Synchronous. Checks whether the specified path is an existing directory or not.
Usage
const {move, copy, root, list, isDir} = require('njfs');
gulp.task('example', async () =>
await gulp.watch(['./src/*.*'], gulp.series('build', async () => {
const dist = root() + 'src';
const dest = root() + 'dist/js';
try {
const files = await list(dist, {extensions:'js, jsx'});
await Promise.all(files.map(async (file) => {
const path = `${dist}/${file}`;
if (!isDir(path)) {
await copy(path, dest);
console.log(`${file} transfered to ${dest}`);
}
}));
} catch (e) {
console.log(e);
}
})
));
Troubleshooting
When you encounter a problem, please open an issue. I would be glad to help you to find a solution if possible.
Author
Github: @orcunsaltik
License
See the LICENSE file for license rights and limitations (MIT).