(rawPath: string)
| 308 | * passes so a forged response never modifies the operator's filesystem. |
| 309 | */ |
| 310 | export function resolveBundleDir(rawPath: string): string { |
| 311 | if (typeof rawPath !== 'string' || rawPath.length === 0) { |
| 312 | throw ApiError.fromEnvelope({ |
| 313 | error: { |
| 314 | code: 'VALIDATION_ERROR', |
| 315 | message: 'Invalid request.', |
| 316 | nextAction: 'Flag `--out` is invalid: must be a non-empty directory path.', |
| 317 | requestId: 'local', |
| 318 | details: { field: 'out', reason: 'must be a non-empty directory path' }, |
| 319 | }, |
| 320 | }); |
| 321 | } |
| 322 | const trimmed = rawPath.endsWith('/') ? rawPath.slice(0, -1) : rawPath; |
| 323 | return isAbsolute(trimmed) ? trimmed : resolve(process.cwd(), trimmed); |
| 324 | } |
| 325 | |
| 326 | /** |
| 327 | * Pick a code-file extension for `<dir>/code.<ext>` based on the §6.3 |
no test coverage detected