@@ -15,14 +15,12 @@ interface GetConfigOptions {
15
15
warn ?: boolean ;
16
16
nullishString ?: boolean ;
17
17
throwErrorIfNotFound ?: boolean ;
18
- throwErrorInTestEnv ?: boolean ; // this is only to test getConfig and should never be set to override defaults
19
18
}
20
19
21
20
const defaultGetConfigOptions : GetConfigOptions = {
22
21
warn : ! isTestEnvironment ,
23
22
nullishString : false ,
24
- throwErrorIfNotFound : false ,
25
- throwErrorInTestEnv : false
23
+ throwErrorIfNotFound : false
26
24
} ;
27
25
28
26
/**
@@ -34,7 +32,6 @@ const defaultGetConfigOptions: GetConfigOptions = {
34
32
* - `throwErrorIfNotFound`: whether to throw an error if the value is missing (default to `false`).
35
33
* - `warn`: whether to warn if the value is missing (default `true` unless in test env).
36
34
* - `nullishString`: if true, returns `''` instead of `undefined` when missing.
37
- * - `throwErrorInTestEnv`: this is to test getConfig and should not be overridden (default to `false`).
38
35
* @returns String value of the env var, or `''` or `undefined` if missing.
39
36
*/
40
37
export function getConfig (
@@ -46,7 +43,7 @@ export function getConfig(
46
43
}
47
44
48
45
// override default options with param options
49
- const { warn, nullishString, throwErrorIfNotFound, throwErrorInTestEnv } = {
46
+ const { warn, nullishString, throwErrorIfNotFound } = {
50
47
...defaultGetConfigOptions ,
51
48
...options
52
49
} ;
@@ -59,10 +56,7 @@ export function getConfig(
59
56
const notFoundMessage = `getConfig("${ key } ") returned null or undefined` ;
60
57
61
58
// error, warn or continue if no value found:
62
- if (
63
- ( throwErrorIfNotFound && ! isTestEnvironment ) ||
64
- ( throwErrorIfNotFound && isTestEnvironment && throwErrorInTestEnv ) // this is just to enable us to test getConfig's error throwing
65
- ) {
59
+ if ( throwErrorIfNotFound && ! isTestEnvironment ) {
66
60
throw new Error ( notFoundMessage ) ;
67
61
}
68
62
if ( warn ) {
0 commit comments