(configObject: Record<string, unknown>, key: string)
| 323 | } |
| 324 | |
| 325 | function validateSizeOption(configObject: Record<string, unknown>, key: string): void { |
| 326 | const value = configObject[key]; |
| 327 | if (value === undefined) return; |
| 328 | if (typeof value === 'string') |
| 329 | try { |
| 330 | configObject[key] = parseSize(value, key); |
| 331 | } catch { |
| 332 | throw new TypeError(`Invalid ${key} in RC file: ${value} (must be a positive number with optional k/m suffix)`); |
| 333 | } |
| 334 | else if (typeof value !== 'number' || Number.isNaN(value) || value <= 0) |
| 335 | throw new TypeError(`Invalid ${key} in RC file: ${value} (must be a positive number)`); |
| 336 | } |
| 337 | |
| 338 | function validateRcConfig(config: unknown, rcPath: string): IRcFileConfig { |
| 339 | if (typeof config !== 'object' || config === null) throw new Error(`RC file ${rcPath} must contain a JSON object`); |
no test coverage detected