-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetConfig.js
More file actions
30 lines (23 loc) · 734 Bytes
/
getConfig.js
File metadata and controls
30 lines (23 loc) · 734 Bytes
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
// Get instance-specific settings from env vars, falling back to config.json file if present
var nconf = require('nconf');
var Q = require('q');
// Set up config sources (env vars and config.json file)
nconf.env()
.file({
file: 'config.json'
});
function get(setting) {
return Q.fcall(function () {
// Check if the setting is in env vars or has already been loaded from
// disk, and if so, return it. If not, try loading from disk.
var value = nconf.get(setting);
if (value === undefined) {
value = Q.ninvoke(nconf, 'load')
.then(function () {
return nconf.get(setting);
});
}
return value;
});
}
exports.get = get;