diff --git a/scripts/core/utils.ts b/scripts/core/utils.ts index 2ad7673c4..e1461bf07 100644 --- a/scripts/core/utils.ts +++ b/scripts/core/utils.ts @@ -114,3 +114,23 @@ export function parseNumber(value: string): number { export function parseList(value: string): string[] { return value.split(',') } + +export function parseBoolean(value: string | boolean | undefined): boolean { + if (value === undefined) return true + if (typeof value === 'boolean') return value + if (typeof value === 'string' && value.toLowerCase() === 'true') return true + + return false +} + +export function parseBooleanOrString(value: string | boolean): string | boolean { + if (value === undefined) return true + if (typeof value === 'boolean') return value + if (typeof value === 'string') { + const normalized = value.toLowerCase() + if (normalized === 'true') return true + if (normalized === 'false') return false + } + + return value +}