src/red/localfilesystem.js
function getLocalNodeFiles(dir) {
    dir = path.resolve(dir);

    var result = [];
    var files = [];
    var icons = [];
    try {
        files = fs.readdirSync(dir);
    } catch(err) {
        return {files: [], icons: []};
    }
    files.sort();
    files.forEach(function(fn) {
        var stats = fs.statSync(path.join(dir,fn));
        if (stats.isFile()) {
            if (/\.js$/.test(fn)) {
                var info = getLocalFile(path.join(dir,fn));
                if (info) {
                    result.push(info);
                }
            }
        } else if (stats.isDirectory()) {
            // Ignore /.dirs/, /lib/ /node_modules/
            if (!/^(\..*|lib|icons|node_modules|test|locales)$/.test(fn)) {
                var subDirResults = getLocalNodeFiles(path.join(dir,fn));
                result = result.concat(subDirResults.files);
                icons = icons.concat(subDirResults.icons);
            } else if (fn === "icons") {
                var iconList = scanIconDir(path.join(dir,fn));
                icons.push({path:path.join(dir,fn),icons:iconList});
            }
        }
    });
    return {files: result, icons: icons};
}
function getLocalNodeFiles(dir) {
    dir = path.resolve(dir);

    var result = [];
    var files = [];
    var icons = [];
    try {
        files = fs.readdirSync(dir);
    } catch(err) {
        return {files: [], icons: []};
    }
    files.sort();
    files.forEach(function(fn) {
        var stats = fs.statSync(path.join(dir,fn));
        if (stats.isFile()) {
            if (/\.js$/.test(fn)) {
                var info = getLocalFile(path.join(dir,fn));
                if (info) {
                    result.push(info);
                }
            }
        } else if (stats.isDirectory()) {
            // Ignore /.dirs/, /lib/ /node_modules/
            if (!/^(\..*|lib|icons|node_modules|test|locales)$/.test(fn)) {
                var subDirResults = getLocalNodeFiles(path.join(dir,fn));
                result = result.concat(subDirResults.files);
                icons = icons.concat(subDirResults.icons);
            } else if (fn === "icons") {
                var iconList = scanIconDir(path.join(dir,fn));
                icons.push({path:path.join(dir,fn),icons:iconList});
            }
        }
    });
    return {files: result, icons: icons};
}
function getLocalNodeFiles ( dir ) { dir = path . resolve ( dir ) ; var result = [ ] ; var files = [ ] ; var icons = [ ] ; try { files = fs . readdirSync ( dir ) ; } catch ( err ) { return { files : [ ] , icons : [ ] } ; } files . sort ( ) ; files . forEach ( function ( fn ) { var stats = fs . statSync ( path . join ( dir , fn ) ) ; if ( stats . isFile ( ) ) { if ( / \.js$ / . test ( fn ) ) { var info = getLocalFile ( path . join ( dir , fn ) ) ; if ( info ) { result . push ( info ) ; } } } else if ( stats . isDirectory ( ) ) { // Ignore /.dirs/, /lib/ /node_modules/ if ( ! / ^(\..*|lib|icons|node_modules|test|locales)$ / . test ( fn ) ) { var subDirResults = getLocalNodeFiles ( path . join ( dir , fn ) ) ; result = result . concat ( subDirResults . files ) ; icons = icons . concat ( subDirResults . icons ) ; } else if ( fn === "icons" ) { var iconList = scanIconDir ( path . join ( dir , fn ) ) ; icons . push ( { path : path . join ( dir , fn ) , icons : iconList } ) ; } } } ) ; return { files : result , icons : icons } ; }
Synchronously walks the directory looking for node files.
Emits 'node-icon-dir' events for an icon dirs found
@param dir the directory to search
@return an array of fully-qualified paths to .js files
Synchronously walks the directory looking for node files . Emits node - icon - dir events for an icon dirs found