Made a module for loading the configuration file.
This commit is contained in:
parent
a426314f3e
commit
3eaf81b40f
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
node_modules
|
||||||
|
settings.json
|
34
configuration.js
Normal file
34
configuration.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
//configuration.js
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
|
//Function for loading and returning the settings.json file, makes one if there isn't one.
|
||||||
|
module.exports = function () {
|
||||||
|
if (!fs.existsSync(__dirname + '/settings.json')) {
|
||||||
|
var settings = {
|
||||||
|
'env' : 'dev',
|
||||||
|
'database' : 'example.com/database',
|
||||||
|
'web_port' : 1024,
|
||||||
|
'amount_of_hours' : 7,
|
||||||
|
'hour_times' : [
|
||||||
|
'8:45 - 9:45',
|
||||||
|
'9:45 - 10:45',
|
||||||
|
'11:10 - 12:10',
|
||||||
|
'12:10 - 13:10',
|
||||||
|
'13:40 - 14:40',
|
||||||
|
'14:40 - 15:40',
|
||||||
|
'15:40 - 16:40'
|
||||||
|
],
|
||||||
|
'school_id' : 934
|
||||||
|
}
|
||||||
|
fs.writeFileSync(__dirname + '/settings.json', JSON.stringify(settings, null, 2));
|
||||||
|
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return JSON.parse(fs.readFileSync(__dirname + '/settings.json'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.argv[2] == 'test') {
|
||||||
|
console.log(module.exports());
|
||||||
|
}
|
Loading…
Reference in a new issue