Merge branch 'feat/inda-383-daily-stat' into 'main'
[ProtonMail-WebClient.git] / applications / pass-extension / tools / env.js
blob1a414cd9c3e571d2de82dd37229293aa164b57e4
1 /**
2 * This utility will get rid of most
3 * false positives when parsing env
4 * variables.
5 */
6 const parseEnvVar = (envVar, fallback, mapTo = (x) => x) => {
7 try {
8 return mapTo(JSON.parse(JSON.stringify(process.env[envVar])));
9 } catch (e) {
10 return fallback;
14 const parseBool = (x) => x === 'true' || x === '1' || x === 1;
16 const BUILD_TARGET = parseEnvVar('BUILD_TARGET', 'chrome', String);
17 const CLEAN_MANIFEST = parseEnvVar('CLEAN_MANIFEST', false, parseBool);
18 const ENV = parseEnvVar('NODE_ENV', 'development', String);
19 const MANIFEST_KEY = parseEnvVar('MANIFEST_KEY', BUILD_TARGET === 'chrome' ? 'chrome:production' : '', String);
20 const REDUX_DEVTOOLS_PORT = parseEnvVar('REDUX_DEVTOOLS_PORT', 8000, parseInt);
21 const RELEASE = parseEnvVar('RELEASE', false, parseBool);
22 const RESUME_FALLBACK = parseEnvVar('RESUME_FALLBACK', false, parseBool);
23 const RUNTIME_RELOAD = parseEnvVar('RUNTIME_RELOAD', false, parseBool);
24 const RUNTIME_RELOAD_PORT = parseEnvVar('RUNTIME_RELOAD_PORT', 8089, parseInt);
25 const WEBPACK_DEV_PORT = parseEnvVar('WEBPACK_DEV_PORT', 8090, Number);
26 const WEBPACK_CIRCULAR_DEPS = parseEnvVar('WEBPACK_CIRCULAR_DEPS', false, Boolean);
28 const HOT_MANIFEST_UPDATE = RUNTIME_RELOAD && parseEnvVar('HOT_MANIFEST_UPDATE', false, parseBool);
30 module.exports = {
31 BUILD_TARGET,
32 CLEAN_MANIFEST,
33 ENV,
34 HOT_MANIFEST_UPDATE,
35 MANIFEST_KEY,
36 REDUX_DEVTOOLS_PORT,
37 RELEASE,
38 RESUME_FALLBACK,
39 RUNTIME_RELOAD_PORT,
40 RUNTIME_RELOAD,
41 WEBPACK_DEV_PORT,
42 WEBPACK_CIRCULAR_DEPS,