1 | "use strict";
|
2 |
|
3 |
|
4 | Object.defineProperty(exports, "__esModule", { value: true });
|
5 | const State_1 = require("./State");
|
6 | const index_1 = require("./index");
|
7 | const ENVIRONMENT_VARIABLE_PREFIX = 'GCB_';
|
8 | function getConfigValue(name, defaultValue) {
|
9 |
|
10 | const envVariable = ENVIRONMENT_VARIABLE_PREFIX + name.toUpperCase();
|
11 | const envValue = process.env[envVariable];
|
12 | const argsValue = State_1.args[name.toLowerCase()];
|
13 |
|
14 |
|
15 | const configValue = ((index_1.getConfig ? index_1.getConfig() : {}) || {})[name];
|
16 | return _firstDefinedValue(argsValue, envValue, defaultValue, configValue);
|
17 | }
|
18 | exports.getConfigValue = getConfigValue;
|
19 | function getFlagValue(name, defaultValue) {
|
20 | const configValue = getConfigValue(name, defaultValue);
|
21 | return configValue === 'true' || configValue === true;
|
22 | }
|
23 | exports.getFlagValue = getFlagValue;
|
24 |
|
25 | function _firstDefinedValue(...values) {
|
26 | for (const value of values) {
|
27 | if (value !== undefined) {
|
28 | return value;
|
29 | }
|
30 | }
|
31 | return undefined;
|
32 | }
|
33 |
|
\ | No newline at end of file |