diff options
| author | jerop <[email protected]> | 2025-06-06 15:32:39 +0000 |
|---|---|---|
| committer | Jerop Kipruto <[email protected]> | 2025-06-06 11:47:37 -0400 |
| commit | 8c28250bb3e6982e1ecff907d9b6c365c6e371d7 (patch) | |
| tree | 38965a751eb38cc53e7e538e7d50bea27acf284f /packages/cli/src/config/settings.ts | |
| parent | 4e9d365407564e0f440bf4645607aa47a1d16bca (diff) | |
Refactor: Improve env var resolution in settings
Refactors the `resolveEnvVarsInObject` function in settings to
explicitly handle primitive types (null, undefined, boolean, number)
at the beginning of the function. This clarifies the logic for
subsequent string, array, and object processing.
Diffstat (limited to 'packages/cli/src/config/settings.ts')
| -rw-r--r-- | packages/cli/src/config/settings.ts | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/packages/cli/src/config/settings.ts b/packages/cli/src/config/settings.ts index 8205a018..427fb898 100644 --- a/packages/cli/src/config/settings.ts +++ b/packages/cli/src/config/settings.ts @@ -110,6 +110,15 @@ function resolveEnvVarsInString(value: string): string { } function resolveEnvVarsInObject<T>(obj: T): T { + if ( + obj === null || + obj === undefined || + typeof obj === 'boolean' || + typeof obj === 'number' + ) { + return obj; + } + if (typeof obj === 'string') { return resolveEnvVarsInString(obj) as unknown as T; } @@ -118,7 +127,7 @@ function resolveEnvVarsInObject<T>(obj: T): T { return obj.map((item) => resolveEnvVarsInObject(item)) as unknown as T; } - if (obj && typeof obj === 'object') { + if (typeof obj === 'object') { const newObj = { ...obj } as T; for (const key in newObj) { if (Object.prototype.hasOwnProperty.call(newObj, key)) { |
