Module loader properly iterates all automatically loaded dependencies [#399]

This commit is contained in:
reality 2013-04-21 14:51:59 +00:00
parent 420d40c848
commit 65b410416c
2 changed files with 9 additions and 5 deletions

View File

@ -1,5 +1,5 @@
{
"ignorable": false,
"help": "http://github.com/reality/depressionbot/blob/master/modules/command/README.md",
"dbKeys": [ "ignores", "bans" ]
"dbKeys": [ "ignores", "bans", "users" ]
}

12
run.js
View File

@ -153,9 +153,13 @@ DBot.prototype.reloadModules = function() {
require('./snippets');
this.instance.removeListeners();
_.each(moduleNames, function(name) {
var name, moduleDir, config;
for(i=0;i<moduleNames.length;i++) {
name = moduleNames[i];
console.log('iterating ' + name);
this.status[name] = true;
var moduleDir = './modules/' + name + '/';
moduleDir = './modules/' + name + '/';
try {
var cacheKey = require.resolve(moduleDir + name);
delete require.cache[cacheKey];
@ -172,7 +176,7 @@ DBot.prototype.reloadModules = function() {
}
// Load the module config data
var config = {};
config = {};
if(_.has(this.db.config, name)) {
config = _.clone(this.db.config[name]);
@ -214,7 +218,7 @@ DBot.prototype.reloadModules = function() {
// Just use the name of the module for now, add dbKey iteration later
this.ddb.createDB(name, config.dbType, {}, function(db) {});
}
}.bind(this));
}
process.nextTick(function() {
_.each(moduleNames, function(name) {