automatically save module load changes [#489]

This commit is contained in:
reality 2013-06-05 21:14:21 +00:00
parent b7a3b6a139
commit 97907603f5
2 changed files with 10 additions and 3 deletions

View File

@ -25,7 +25,7 @@ var admin = function(dbot) {
},
'setConfig': function(configKey, newOption, callback) {
var configPath = dbot.config;
var configPath = dbot.customConfig;
configKey = configKey.split('.');
for(var i=0;i<configKey.length-1;i++) {
@ -35,6 +35,10 @@ var admin = function(dbot) {
return;
}
}
this.internalAPI.saveConfig();
dbot.reloadConfig();
callback(true);
},
'saveConfig': function() {

View File

@ -120,7 +120,8 @@ var commands = function(dbot) {
'load': function(event) {
var moduleName = event.params[1];
if(!_.include(dbot.config.moduleNames, moduleName)) {
dbot.config.moduleNames.push(moduleName);
dbot.customConfig.moduleNames.push(moduleName);
this.internalAPI.saveConfig();
dbot.reloadModules();
process.nextTick(function() {
if(dbot.status[moduleName] === true) {
@ -148,7 +149,9 @@ var commands = function(dbot) {
var cacheKey = require.resolve(moduleDir + moduleName);
delete require.cache[cacheKey];
} catch(err) { }
dbot.config.moduleNames = _.without(dbot.config.moduleNames, moduleName);
dbot.customConfig.moduleNames = _.without(dbot.config.moduleNames, moduleName);
this.internalAPI.saveConfig();
dbot.reloadModules();
process.nextTick(function() {