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) {
|
var DBot = function(timers) {
|
||||||
// Load external files
|
// Load external files
|
||||||
|
var requiredConfigKeys = [ 'name', 'servers', 'admin', 'moduleNames', 'language' ];
|
||||||
try {
|
try {
|
||||||
this.config = JSON.parse(fs.readFileSync('config.json', 'utf-8'));
|
this.config = JSON.parse(fs.readFileSync('config.json', 'utf-8'));
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
@ -16,6 +17,13 @@ var DBot = function(timers) {
|
|||||||
process.exit();
|
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;
|
var rawDB;
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user