From 8c28250bb3e6982e1ecff907d9b6c365c6e371d7 Mon Sep 17 00:00:00 2001 From: jerop Date: Fri, 6 Jun 2025 15:32:39 +0000 Subject: 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. --- packages/cli/src/config/settings.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'packages/cli/src/config/settings.ts') 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(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(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)) { -- cgit v1.2.3