forked from GitHub/dbot
Try to satisfy dependencies automatically [#231]
This commit is contained in:
parent
55815702dc
commit
4b5aceea49
18
run.js
18
run.js
@ -157,7 +157,6 @@ DBot.prototype.reloadModules = function() {
|
|||||||
this.instance.removeListeners();
|
this.instance.removeListeners();
|
||||||
|
|
||||||
moduleNames.each(function(name) {
|
moduleNames.each(function(name) {
|
||||||
this.status[name] = true;
|
|
||||||
var moduleDir = './modules/' + name + '/';
|
var moduleDir = './modules/' + name + '/';
|
||||||
var cacheKey = require.resolve(moduleDir + name);
|
var cacheKey = require.resolve(moduleDir + name);
|
||||||
delete require.cache[cacheKey];
|
delete require.cache[cacheKey];
|
||||||
@ -170,6 +169,8 @@ DBot.prototype.reloadModules = function() {
|
|||||||
delete require.cache[webKey];
|
delete require.cache[webKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.status[name] = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Load the module config data
|
// Load the module config data
|
||||||
var config = {};
|
var config = {};
|
||||||
@ -191,19 +192,14 @@ DBot.prototype.reloadModules = function() {
|
|||||||
// Invalid or no config data
|
// Invalid or no config data
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shit out if dependencies not met
|
// Don't shit out if dependencies not met
|
||||||
if(_.has(config, 'dependencies')) {
|
if(_.has(config, 'dependencies')) {
|
||||||
var unmetDependencies = _.reduce(config.dependencies, function(memo, dependency) {
|
_.each(config.dependencies, function(dependency) {
|
||||||
if(!_.include(moduleNames, dependency)) {
|
if(!_.include(moduleNames, dependency)) {
|
||||||
memo.push(dependency);
|
console.log('Warning: Automatically loading ' + dependency);
|
||||||
|
moduleNames.push(dependency);
|
||||||
}
|
}
|
||||||
return memo;
|
}, this);
|
||||||
}, [], this);
|
|
||||||
|
|
||||||
if(unmetDependencies.length != 0) {
|
|
||||||
this.status[name] = 'Dependencies not met: ' + unmetDependencies;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate missing DB keys
|
// Generate missing DB keys
|
||||||
|
Loading…
Reference in New Issue
Block a user