njfs

1.2.5 • Public • Published

Node Js File System

Build Status devDependencies Status Maintainability Snyk Vulnerabilities for GitHub Repo npm NPM Version contributions welcome

A small collection of sync & async filesystem functions for Node Js.

Install

npm install --save-dev njfs

Methods

  1. unix(path): Synchronous. Returns path with unix-like directory separators.
  2. root(path): Synchronous. Returns the root directory of the package.
  3. list(path, opts): Asynchronous. Returns the list of files and folders of the given path.
  4. move(path, dest): Asynchronous. Moves files or folders.
  5. copy(path, dest): Asynchronous. Copies files or folders.
  6. isFile(path): Synchronous. Checks whether the specified path is an existing file or not.
  7. 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).

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i njfs

    Weekly Downloads

    500

    Version

    1.2.5

    License

    MIT

    Unpacked Size

    8.02 kB

    Total Files

    7

    Last publish

    Collaborators

    • orcunsaltik