2018-06-09 23:34:06 +00:00
|
|
|
process.on('uncaughtException', function (err) {
|
|
|
|
console.error('Uncaught Exception occured!');
|
|
|
|
console.error(err.stack);
|
|
|
|
});
|
|
|
|
var configLocation = __dirname+'/../conf.json';
|
|
|
|
var fs = require('fs');
|
|
|
|
var jsonfile = require("jsonfile");
|
|
|
|
var config = jsonfile.readFileSync(configLocation);
|
|
|
|
var processArgv = process.argv.splice(2,process.argv.length)
|
|
|
|
var arguments = {};
|
|
|
|
processArgv.forEach(function(val) {
|
|
|
|
var theSplit = val.split('=');
|
|
|
|
var index = theSplit[0];
|
|
|
|
var value = theSplit[1];
|
2018-07-11 21:09:04 +00:00
|
|
|
if(index === 'addToConfig'){
|
2018-06-09 23:34:06 +00:00
|
|
|
try{
|
2018-07-11 21:09:04 +00:00
|
|
|
value = JSON.parse(value)
|
|
|
|
config = Object.assign(config,value)
|
2018-06-09 23:34:06 +00:00
|
|
|
}catch(err){
|
2018-07-11 21:09:04 +00:00
|
|
|
console.log('Not a valid Data set. "addToConfig" value must be a JSON string. You may need to wrap it in singles quotes.')
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
if(value==='DELETE'){
|
|
|
|
delete(config[index])
|
|
|
|
}else{
|
|
|
|
try{
|
|
|
|
config[index] = JSON.parse(value);
|
|
|
|
}catch(err){
|
|
|
|
config[index] = value;
|
|
|
|
}
|
2018-06-09 23:34:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log(index + ': ' + value);
|
|
|
|
});
|
|
|
|
|
|
|
|
jsonfile.writeFile(configLocation,config,{spaces: 2},function(){
|
|
|
|
console.log('Changes Complete. Here is what it is now.')
|
|
|
|
console.log(JSON.stringify(config,null,2))
|
|
|
|
})
|