forked from synclounge/synclounge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SettingsHelper.js
36 lines (33 loc) · 943 Bytes
/
SettingsHelper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const args = require('args-parser')(process.argv);
const settings = require('./settings.json');
const defaults = {
webroot: '',
serverroot: '',
accessUrl: '',
autoJoin: false,
autoJoinServer: '',
autoJoinRoom: '',
autoJoinPassword: '',
};
module.exports = function () {
const fields = [
'webroot',
'serverroot',
'accessUrl',
'autoJoin',
'autoJoinServer',
'autoJoinRoom',
'autoJoinPassword',
];
// Load and export our settings in preference of ENV -> args
const output = {};
for (let i = 0; i < fields.length; i++) {
const setting = fields[i];
// console.log('Processing setting', setting)
// console.log(args[setting], process.env[setting], defaults[setting])
output[setting] = args[setting] || process.env[setting] || settings[setting] || defaults[setting];
process.env[setting] = output[setting];
}
// console.log('Our settings are', output)
return output;
};