src/red/localfilesystem.js
function scanTreeForNodesModules(moduleName) {
    var dir = settings.coreNodesDir;
    var results = [];
    var userDir;

    if (settings.userDir) {
        userDir = path.join(settings.userDir,"node_modules");
        results = scanDirForNodesModules(userDir,moduleName);
        results.forEach(function(r) { r.local = true; });
    }

    if (dir) {
        var up = path.resolve(path.join(dir,".."));
        while (up !== dir) {
            var pm = path.join(dir,"node_modules");
            if (pm != userDir) {
                results = results.concat(scanDirForNodesModules(pm,moduleName));
            }
            dir = up;
            up = path.resolve(path.join(dir,".."));
        }
    }
    return results;
}
function scanTreeForNodesModules(moduleName) {
    var dir = settings.coreNodesDir;
    var results = [];
    var userDir;

    if (settings.userDir) {
        userDir = path.join(settings.userDir,"node_modules");
        results = scanDirForNodesModules(userDir,moduleName);
        results.forEach(function(r) { r.local = true; });
    }

    if (dir) {
        var up = path.resolve(path.join(dir,".."));
        while (up !== dir) {
            var pm = path.join(dir,"node_modules");
            if (pm != userDir) {
                results = results.concat(scanDirForNodesModules(pm,moduleName));
            }
            dir = up;
            up = path.resolve(path.join(dir,".."));
        }
    }
    return results;
}
function scanTreeForNodesModules ( moduleName ) { var dir = settings . coreNodesDir ; var results = [ ] ; var userDir ; if ( settings . userDir ) { userDir = path . join ( settings . userDir , "node_modules" ) ; results = scanDirForNodesModules ( userDir , moduleName ) ; results . forEach ( function ( r ) { r . local = true ; } ) ; } if ( dir ) { var up = path . resolve ( path . join ( dir , ".." ) ) ; while ( up !== dir ) { var pm = path . join ( dir , "node_modules" ) ; if ( pm != userDir ) { results = results . concat ( scanDirForNodesModules ( pm , moduleName ) ) ; } dir = up ; up = path . resolve ( path . join ( dir , ".." ) ) ; } } return results ; }
Scans the node_modules path for nodes
@param moduleName the name of the module to be found
@return a list of node modules: {dir,package}
Scans the node_modules path for nodes