2022-03-03 18:24:41 +01:00
|
|
|
/* eslint-disable no-console */
|
2022-01-28 15:29:04 +01:00
|
|
|
function load(envName) {
|
|
|
|
return {
|
|
|
|
...loadConfig(envName),
|
|
|
|
...loadConfig("local"),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function log(configObj) {
|
|
|
|
const repeatNum = 50;
|
|
|
|
console.log(`${"=".repeat(repeatNum)}\nenvConfig`);
|
|
|
|
console.log(JSON.stringify(configObj, null, 2));
|
|
|
|
console.log(`${"=".repeat(repeatNum)}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadConfig(configName) {
|
|
|
|
try {
|
|
|
|
return require(`./${configName}.json`);
|
|
|
|
} catch (e) {
|
|
|
|
if (e instanceof Error && e.code === "MODULE_NOT_FOUND") {
|
|
|
|
return {};
|
|
|
|
} else {
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
load,
|
|
|
|
log,
|
|
|
|
};
|