forked from andrefs/node-voucher-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
32 lines (29 loc) · 1.02 KB
/
config.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
import fs from 'fs';
let debug = require('debug')('config');
// Config files priority (only one gets loaded):
// - test (if NODE_ENV === test
// - local (if config/config.local.js exists)
// - production (if NODE_ENV === production)
// - development (if NODE_ENV === development)
if(process.env.NODE_ENV === 'test'){
let file = './config/config.test.js';
debug(`Loading config info from ${file}`);
module.exports = require(file);
} else {
try {
let file = './config/config.local.js';
fs.accessSync(file);
debug(`Loading config info from ${file}`);
module.exports = require(file);
} catch(er){
if(process.env.NODE_ENV === 'production'){
let file = './config/config.production.js';
debug(`Loading config info from ${file}`);
module.exports = require(file);
} else {
let file = './config/config.development.js';
debug(`Loading config info from ${file}`);
module.exports = require(file);
}
}
}