3 const common
= require('../src/common');
5 const defaultEnvironment
= 'development';
6 const testEnvironment
= 'test';
8 function Config(environment
) {
9 environment
= environment
|| defaultEnvironment
;
10 const defaultConfig
= require('./default');
11 let envConfig
= require(`./${environment}`); // eslint-disable-line security/detect-non-literal-require
12 if (!Array
.isArray(envConfig
)) {
13 envConfig
= Array(envConfig
);
15 // We support arrays of config options in env to allow e.g. resetting an existing array
16 const combinedConfig
= common
.mergeDeep(defaultConfig
, ...envConfig
, { environment
});
17 if (!environment
.includes(testEnvironment
)) {
18 /* istanbul ignore next */
19 common
.freezeDeep(combinedConfig
);
21 return combinedConfig
;
24 module
.exports
= Config
;