1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-06 09:20:43 +01:00
bitwarden-browser/apps/web/config.js

51 lines
923 B
JavaScript
Raw Normal View History

function load(envName) {
const base = require("./config/base.json");
const env = loadConfig(envName);
const local = loadConfig("local");
2021-12-17 15:57:11 +01:00
return {
...base,
...env,
...local,
2021-12-17 15:57:11 +01:00
dev: {
...base.dev,
...env.dev,
...local.dev,
},
flags: {
...base.flags,
...env.flags,
...local.flags,
},
devFlags: {
...base.devFlags,
...env.devFlags,
...local.devFlags,
2021-12-17 15:57:11 +01:00
},
};
}
function log(configObj) {
2021-12-17 15:57:11 +01:00
const repeatNum = 50;
console.log(`${"=".repeat(repeatNum)}\nenvConfig`);
console.log(JSON.stringify(configObj, null, 2));
console.log(`${"=".repeat(repeatNum)}`);
}
function loadConfig(configName) {
2021-12-17 15:57:11 +01:00
try {
return require(`./config/${configName}.json`);
} catch (e) {
if (e instanceof Error && e.code === "MODULE_NOT_FOUND") {
return {};
} else {
throw e;
}
2021-12-17 15:57:11 +01:00
}
}
module.exports = {
2021-12-17 15:57:11 +01:00
load,
log,
};