-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·29 lines (25 loc) · 969 Bytes
/
index.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
import fs from 'fs'
import _debug from 'debug'
import config from './_base'
const debug = _debug('app:config')
debug('Create configuration.')
debug(`Apply environment overrides for NODE_ENV "${config.env}".`)
// Check if the file exists before attempting to require it, this
// way we can provide better error reporting that overrides
// weren't applied simply because the file didn't exist.
const overridesFilename = `_${config.env}`
let hasOverridesFile
try {
fs.lstatSync(`${__dirname}/${overridesFilename}.js`)
hasOverridesFile = true
} catch (e) {}
// Overrides file exists, so we can attempt to require it.
// We intentionally don't wrap this in a try/catch as we want
// the Node process to exit if an error occurs.
let overrides
if (hasOverridesFile) {
overrides = require(`./${overridesFilename}`).default(config)
} else {
debug(`No configuration overrides found for NODE_ENV "${config.env}"`)
}
export default Object.assign({}, config, overrides)