mirror of
https://github.com/reality/dbot.git
synced 2024-11-27 14:29:29 +01:00
add ability to unload a module whose file has been deleted
This commit is contained in:
parent
dfa1e40a8b
commit
6a968d5945
@ -173,8 +173,10 @@ var commands = function(dbot) {
|
|||||||
var moduleName = event.params[1];
|
var moduleName = event.params[1];
|
||||||
if(_.include(moduleNames, moduleName)) {
|
if(_.include(moduleNames, moduleName)) {
|
||||||
var moduleDir = '../' + moduleName + '/';
|
var moduleDir = '../' + moduleName + '/';
|
||||||
var cacheKey = require.resolve(moduleDir + moduleName);
|
try {
|
||||||
delete require.cache[cacheKey];
|
var cacheKey = require.resolve(moduleDir + moduleName);
|
||||||
|
delete require.cache[cacheKey];
|
||||||
|
} catch(err) { }
|
||||||
dbot.config.moduleNames = _.without(dbot.config.moduleNames, moduleName);
|
dbot.config.moduleNames = _.without(dbot.config.moduleNames, moduleName);
|
||||||
dbot.reloadModules();
|
dbot.reloadModules();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user