(value: string, name: string)
| 154 | } |
| 155 | |
| 156 | function parseSize(value: string, name: string): number { |
| 157 | const trimmed = value.trim(); |
| 158 | const match = trimmed.match(/^(\d+(?:\.\d+)?)\s*([KMkm])?$/); |
| 159 | |
| 160 | if (!match || !match[1]) |
| 161 | throw new Error(`${name} must be a positive number with optional k/K (×1024) or m/M (×1024²) suffix: ${value}`); |
| 162 | |
| 163 | const numericPart = Number(match[1]); |
| 164 | const suffix = match[2]?.toLowerCase(); |
| 165 | |
| 166 | let bytes: number; |
| 167 | if (suffix === 'k') bytes = numericPart * 1024; |
| 168 | else if (suffix === 'm') bytes = numericPart * 1024 * 1024; |
| 169 | else bytes = numericPart; |
| 170 | |
| 171 | bytes = Math.round(bytes); |
| 172 | |
| 173 | if (bytes <= 0 || !Number.isFinite(bytes)) throw new Error(`${name} must be a positive integer: ${value}`); |
| 174 | |
| 175 | return bytes; |
| 176 | } |
| 177 | |
| 178 | function findRcFile(customConfigPath?: string): string | undefined { |
| 179 | // If --config specified, use that exclusively |
no outgoing calls
no test coverage detected