3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-23 20:39:25 +01:00

add ability to unload a module whose file has been deleted

This commit is contained in:
John Maguire 2013-03-20 19:34:43 -04:00
parent dfa1e40a8b
commit 6a968d5945

View File

@ -173,8 +173,10 @@ var commands = function(dbot) {
var moduleName = event.params[1];
if(_.include(moduleNames, moduleName)) {
var moduleDir = '../' + moduleName + '/';
var cacheKey = require.resolve(moduleDir + moduleName);
delete require.cache[cacheKey];
try {
var cacheKey = require.resolve(moduleDir + moduleName);
delete require.cache[cacheKey];
} catch(err) { }
dbot.config.moduleNames = _.without(dbot.config.moduleNames, moduleName);
dbot.reloadModules();