3 const common
= require('../src/common');
5 const defaultEnvironment
= 'development';
6 const testEnvironment
= 'test';
9 * Merge environment-specific config objects on top of defaults.
10 * @param {string=} environment from NODE_ENV
11 * @returns {object} config
13 function Config(environment
) {
14 environment
= environment
|| defaultEnvironment
;
15 const defaultConfig
= require('./default');
16 let envConfig
= require(`./${environment}`); // eslint-disable-line security/detect-non-literal-require
17 if (!Array
.isArray(envConfig
)) {
18 envConfig
= Array(envConfig
);
20 // We support arrays of config options in env to allow e.g. resetting an existing array
21 const combinedConfig
= common
.mergeDeep(defaultConfig
, ...envConfig
, { environment
});
22 if (!environment
.includes(testEnvironment
)) {
23 /* istanbul ignore next */
24 common
.freezeDeep(combinedConfig
);
26 return combinedConfig
;
29 module
.exports
= Config
;