All files / js runtime_env.js

68.96% Statements 20/29
50% Branches 4/8
50% Functions 2/4
68.96% Lines 20/29

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 3073x 73x 73x 73x 1131439x 1131439x 1131439x 1131439x 1131439x 73x 73x           73x 73x 1071611x 1071611x 1071611x 73x 73x         73x 73x  
// runtime_env.js — Runtime environment helpers
// Provides access to environment variables and flags.
 
export function getEnv(key, defaultVal) {
    if (typeof process !== 'undefined' && process.env) {
        return process.env[key] ?? defaultVal ?? '';
    }
    return defaultVal ?? '';
}
 
export function getEnvObject() {
    if (typeof process !== 'undefined' && process.env) {
        return process.env;
    }
    return {};
}
 
export function envFlag(key) {
    const val = getEnv(key);
    return val && val !== '0' && val.toLowerCase() !== 'false' ? val : null;
}
 
export function writeStderr(msg) {
    if (typeof process !== 'undefined' && process.stderr) {
        process.stderr.write(msg);
    }
}
 
export default { getEnv, getEnvObject, envFlag, writeStderr };