@@ -15,14 +15,12 @@ interface GetConfigOptions {
1515 warn ?: boolean ;
1616 nullishString ?: boolean ;
1717 throwErrorIfNotFound ?: boolean ;
18- throwErrorInTestEnv ?: boolean ; // this is only to test getConfig and should never be set to override defaults
1918}
2019
2120const defaultGetConfigOptions : GetConfigOptions = {
2221 warn : ! isTestEnvironment ,
2322 nullishString : false ,
24- throwErrorIfNotFound : false ,
25- throwErrorInTestEnv : false
23+ throwErrorIfNotFound : false
2624} ;
2725
2826/**
@@ -34,7 +32,6 @@ const defaultGetConfigOptions: GetConfigOptions = {
3432 * - `throwErrorIfNotFound`: whether to throw an error if the value is missing (default to `false`).
3533 * - `warn`: whether to warn if the value is missing (default `true` unless in test env).
3634 * - `nullishString`: if true, returns `''` instead of `undefined` when missing.
37- * - `throwErrorInTestEnv`: this is to test getConfig and should not be overridden (default to `false`).
3835 * @returns String value of the env var, or `''` or `undefined` if missing.
3936 */
4037export function getConfig (
@@ -46,7 +43,7 @@ export function getConfig(
4643 }
4744
4845 // override default options with param options
49- const { warn, nullishString, throwErrorIfNotFound, throwErrorInTestEnv } = {
46+ const { warn, nullishString, throwErrorIfNotFound } = {
5047 ...defaultGetConfigOptions ,
5148 ...options
5249 } ;
@@ -59,10 +56,7 @@ export function getConfig(
5956 const notFoundMessage = `getConfig("${ key } ") returned null or undefined` ;
6057
6158 // 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 ) {
6660 throw new Error ( notFoundMessage ) ;
6761 }
6862 if ( warn ) {
0 commit comments