lib/expose.js
function load(target, opts) {
    target = path.resolve(target);

    debug("Load enter: " + target);

    if (fs.statSync(target).isDirectory()) {
        var files = fs.readdirSync(target), len = files.length, file;
        for (var i = 0; i < len; i++) {
            file = files[i];
            var fullPath = target + sep + file;

            if (fs.statSync(fullPath).isDirectory() && opts.recurse) {
                load(fullPath, opts);
            } else if (test(fullPath, opts.grep, opts.ungrep)) {
                importModule(fullPath, opts.scope, opts.fn);
            }
        }
    } else if (test(target, opts.grep, opts.ungrep)) {
        importModule(target, opts.scope, opts.fn);
    }
}
function load(target, opts) {
    target = path.resolve(target);

    debug("Load enter: " + target);

    if (fs.statSync(target).isDirectory()) {
        var files = fs.readdirSync(target), len = files.length, file;
        for (var i = 0; i < len; i++) {
            file = files[i];
            var fullPath = target + sep + file;

            if (fs.statSync(fullPath).isDirectory() && opts.recurse) {
                load(fullPath, opts);
            } else if (test(fullPath, opts.grep, opts.ungrep)) {
                importModule(fullPath, opts.scope, opts.fn);
            }
        }
    } else if (test(target, opts.grep, opts.ungrep)) {
        importModule(target, opts.scope, opts.fn);
    }
}
function load ( target , opts ) { target = path . resolve ( target ) ; debug ( "Load enter: " + target ) ; if ( fs . statSync ( target ) . isDirectory ( ) ) { var files = fs . readdirSync ( target ) , len = files . length , file ; for ( var i = 0 ; i < len ; i ++ ) { file = files [ i ] ; var fullPath = target + sep + file ; if ( fs . statSync ( fullPath ) . isDirectory ( ) && opts . recurse ) { load ( fullPath , opts ) ; } else if ( test ( fullPath , opts . grep , opts . ungrep ) ) { importModule ( fullPath , opts . scope , opts . fn ) ; } } } else if ( test ( target , opts . grep , opts . ungrep ) ) { importModule ( target , opts . scope , opts . fn ) ; } }
Perform importing on the given target based on the
given options. The target can be a directory to
walk or it can be a file.

The `opts` passed in should be the same format
as those built with `defaultOpts`.

@param {String} target The file or dir to target.
@param {Object} opts The options to use for importing.
@api private
Perform importing on the given target based on the given options . The target can be a directory to walk or it can be a file .