@@ -14,22 +14,19 @@ export function getEnvVar(key: string): string | undefined {
1414interface GetConfigOptions {
1515 warn ?: boolean ;
1616 nullishString ?: boolean ;
17- throwErrorIfNotFound ?: boolean ;
1817}
1918
2019const DEFAULT_GET_CONFIG_OPTIONS : GetConfigOptions = {
2120 warn : ! isTestEnvironment ,
22- nullishString : false ,
23- throwErrorIfNotFound : false
21+ nullishString : false
2422} ;
2523
2624/**
2725 * Returns a string config value from environment variables.
28- * Logs a warning or throws an error if the value is missing, if `warn` and `throwErrorIfNotFound` are true in options
26+ * Logs a warning if the value is missing, if `warn` is true in options
2927 *
3028 * @param key - The environment variable key to fetch.
3129 * @param options - Optional settings:
32- * - `throwErrorIfNotFound`: whether to throw an error if the value is missing (default to `false`).
3330 * - `warn`: whether to warn if the value is missing (default `true` unless in test env).
3431 * - `nullishString`: if true, returns `''` instead of `undefined` when missing.
3532 * @returns String value of the env var, or `''` or `undefined` if missing.
@@ -43,7 +40,7 @@ export function getConfig(
4340 }
4441
4542 // override default options with param options
46- const { warn, nullishString, throwErrorIfNotFound } = {
43+ const { warn, nullishString } = {
4744 ...DEFAULT_GET_CONFIG_OPTIONS ,
4845 ...options
4946 } ;
@@ -55,10 +52,7 @@ export function getConfig(
5552 if ( value == null || value === '' ) {
5653 const notFoundMessage = `getConfig("${ key } ") returned null or undefined` ;
5754
58- // error, warn or continue if no value found:
59- if ( throwErrorIfNotFound && ! isTestEnvironment ) {
60- throw new Error ( notFoundMessage ) ;
61- }
55+ // warn or continue if no value found:
6256 if ( warn ) {
6357 console . warn ( notFoundMessage ) ;
6458 }
0 commit comments