mirror of
https://github.com/reality/dbot.git
synced 2024-11-30 16:09:27 +01:00
add check to make sure module exists before attempting to load it
This commit is contained in:
parent
6a968d5945
commit
3dd24e832d
9
run.js
9
run.js
@ -155,9 +155,16 @@ 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 + '/';
|
||||||
|
try {
|
||||||
var cacheKey = require.resolve(moduleDir + name);
|
var cacheKey = require.resolve(moduleDir + name);
|
||||||
delete require.cache[cacheKey];
|
delete require.cache[cacheKey];
|
||||||
|
} catch(err) {
|
||||||
|
this.status[name] = 'Error loading module: ' + err + ' ' + err.stack.split('\n')[2].trim();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var webKey = require.resolve(moduleDir + 'web');
|
var webKey = require.resolve(moduleDir + 'web');
|
||||||
@ -167,8 +174,6 @@ 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 = {};
|
||||||
|
Loading…
Reference in New Issue
Block a user