Removed settings file

This commit is contained in:
Sam 2018-07-20 22:28:08 +10:00
parent 22c43c6ce6
commit 4582d8694f
2 changed files with 13 additions and 14 deletions

View File

@ -1,7 +1,14 @@
var jsonfile = require('jsonfile')
const args = require('args-parser')(process.argv) const args = require('args-parser')(process.argv)
const defaults = {
'webroot': '',
'serverroot': '',
'accessUrl': '',
'autoJoin': false,
'autoJoinServer': '',
'autoJoinRoom': '',
'autoJoinPassword': ''
}
module.exports = function () { module.exports = function () {
const fields = [ const fields = [
'webroot', 'webroot',
@ -12,21 +19,11 @@ module.exports = function () {
'autoJoinRoom', 'autoJoinRoom',
'autoJoinPassword' 'autoJoinPassword'
] ]
// Load and export our settings in preference of ENV -> settings.json -> example_settings.json // Load and export our settings in preference of ENV -> args
let output = {} let output = {}
let settingsFile
try {
settingsFile = require('./settings.json')
} catch (e) {
console.log('Creating default settings.json')
let defaults = require('./example_settings.json')
jsonfile.writeFileSync('./settings.json', defaults)
settingsFile = defaults
}
let defaults = require('./example_settings.json')
for (let i = 0; i < fields.length; i++) { for (let i = 0; i < fields.length; i++) {
let setting = fields[i] let setting = fields[i]
output[setting] = args[setting] || process.env[setting] || settingsFile[setting] || defaults[setting] output[setting] = args[setting] || process.env[setting] || defaults[setting]
} }
return output return output
} }

View File

@ -1,5 +1,7 @@
var git = require('git-rev-sync') var git = require('git-rev-sync')
console.log('Production env', process.env)
module.exports = { module.exports = {
NODE_ENV: '"production"', NODE_ENV: '"production"',
gitHash: '"' + git.short() + '"', gitHash: '"' + git.short() + '"',