forked from GitHub/dbot
Check for required keys in config
This commit is contained in:
parent
a431d4c636
commit
918a3c4540
8
run.js
8
run.js
@ -5,6 +5,7 @@ require('./snippets');
|
||||
|
||||
var DBot = function(timers) {
|
||||
// Load external files
|
||||
var requiredConfigKeys = [ 'name', 'servers', 'admin', 'moduleNames', 'language' ];
|
||||
try {
|
||||
this.config = JSON.parse(fs.readFileSync('config.json', 'utf-8'));
|
||||
} catch(err) {
|
||||
@ -16,6 +17,13 @@ var DBot = function(timers) {
|
||||
process.exit();
|
||||
}
|
||||
}
|
||||
requiredConfigKeys.each(function(key) {
|
||||
if(!this.config.hasOwnProperty(key)) {
|
||||
console.log('Error: Please set a value for ' + key + ' in ' +
|
||||
'config.json. Stopping.');
|
||||
process.exit();
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
var rawDB;
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user