node package manager

norris-fs

NORRIS-fs - a toolkit for manipulating file systems

NORRIS-fs is a toolkit to augment the current node's fs module, providing a set of useful methods like walk() that recursively walks a root path.

Install

npm install norris-fs

Usage

NORRIS-fs contains a bunch of file system utilities:

walk(basepath, *options callback(err, files))

Recursively walks a base directory (does not follow symlinks) and returns a list of JS files found in that directory.

The basepath argument must be an absolute path. Support for relative paths will be added in the future.

The options argument is OPTIONAL. If provided, it should be an object with these parameters set (if not set, they will fallback to the default value):

options = {
    ignoreSys : true,   // if set to false, it will load system
                        // files too (all filenames with a dot
                        // prefix are considered sys files

    ignoreExt : []      // an array of file extensions to exclude
                        // from the return array. For example,
                        // if ignoreExt = ['.js', '.php'], it will
                        // not return JS files and PHP files.
}

The callback argument expects a function with 2 parameters: err and files, the former which if not null would show that there's an error that caused the operation to fail, while the latter would contain all the found files (in relative filenames) if the operation is successful.

Example

var nfs = require('norris-fs').make(); // don't forget the make()!

nfs.walk('/some/directory', function onWalk(err, files) {
    /**
    The argument "files" should contain all JS files in your dir specified
    by the "basepath" argument. It will ignore:

    1.  Directories starting with a dot "."
    2.  Files not ending with .js
    **/

    console.log(files);
});