Skip to content

Instantly share code, notes, and snippets.

@mrutid
Created May 14, 2012 13:18
Show Gist options
  • Select an option

  • Save mrutid/2693913 to your computer and use it in GitHub Desktop.

Select an option

Save mrutid/2693913 to your computer and use it in GitHub Desktop.
var async = require('async');
var fs = require('fs');
var initArr = [];
exports.init = function(directory, context, callback){
var files = fs.readdirSync(directory);
console.log('Files Readed:' + files);
files.forEach(function(element) {
var module = require(directory + element);
initArr.push(function(cb) {
module.init(context, function (err, result) {cb(null, err||result)});
});
});
async.series(initArr, function(err, result) {
//never throws error
console.log('Listeners Addons Loaded:');
console.dir(result);
callback();
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment