(value: unknown, fallback = false)
| 79 | } |
| 80 | |
| 81 | export function parseOptionalBoolean(value: unknown, fallback = false): boolean { |
| 82 | if (typeof value === 'boolean') { |
| 83 | return value; |
| 84 | } |
| 85 | const normalized = String(value ?? '').trim().toLowerCase(); |
| 86 | if (!normalized) { |
| 87 | return fallback; |
| 88 | } |
| 89 | if (['1', 'true', 'yes', 'y', 'on'].includes(normalized)) { |
| 90 | return true; |
| 91 | } |
| 92 | if (['0', 'false', 'no', 'n', 'off'].includes(normalized)) { |
| 93 | return false; |
| 94 | } |
| 95 | return fallback; |
| 96 | } |
| 97 | |
| 98 | export function normalizeServeHost(options: Pick<ServeCliOptions, 'host' | 'publicBind'>): string | null { |
| 99 | return options.host ?? (options.publicBind ? '0.0.0.0' : null); |
no outgoing calls
no test coverage detected