lib/plugins.js
function load(dirPath) {

    findFiles(dirPath, function(filePath){
        collection.push( require(filePath) );
    })

    function findFiles(dirPath, callback){
        fs.readdir(dirPath, function(err, files) {
            files.forEach(function(file){
                fs.stat(dirPath + '/' + file, function(err, stats) {
                    if(stats.isFile()) {
                        callback(dirPath + '/' + file);
                    }
                    if(stats.isDirectory()) {
                        getDirectoryFiles(dirPath + '/' + file, callback);
                    }
                });
            });
        });
    }
}
function load(dirPath) {

    findFiles(dirPath, function(filePath){
        collection.push( require(filePath) );
    })

    function findFiles(dirPath, callback){
        fs.readdir(dirPath, function(err, files) {
            files.forEach(function(file){
                fs.stat(dirPath + '/' + file, function(err, stats) {
                    if(stats.isFile()) {
                        callback(dirPath + '/' + file);
                    }
                    if(stats.isDirectory()) {
                        getDirectoryFiles(dirPath + '/' + file, callback);
                    }
                });
            });
        });
    }
}
function load ( dirPath ) { findFiles ( dirPath , function ( filePath ) { collection . push ( require ( filePath ) ) ; } ) function findFiles ( dirPath , callback ) { fs . readdir ( dirPath , function ( err , files ) { files . forEach ( function ( file ) { fs . stat ( dirPath + '/' + file , function ( err , stats ) { if ( stats . isFile ( ) ) { callback ( dirPath + '/' + file ) ; } if ( stats . isDirectory ( ) ) { getDirectoryFiles ( dirPath + '/' + file , callback ) ; } } ) ; } ) ; } ) ; } }
load any file that is found in the plugins directory
load any file that is found in the plugins directory