Read + validate the motion sidecar; print the error and exit on a bad spec.
(specPath: string, json: boolean)
| 420 | |
| 421 | /** Read + validate the motion sidecar; print the error and exit on a bad spec. */ |
| 422 | function resolveMotionSpec(specPath: string, json: boolean): MotionSpec { |
| 423 | const parsed = readMotionSpec(specPath); |
| 424 | if (parsed.ok) return parsed.spec; |
| 425 | |
| 426 | const message = `Invalid motion spec ${specPath}: ${parsed.errors.join("; ")}`; |
| 427 | if (json) { |
| 428 | console.log( |
| 429 | JSON.stringify( |
| 430 | withMeta({ |
| 431 | schemaVersion: INSPECT_SCHEMA_VERSION, |
| 432 | ok: false, |
| 433 | error: message, |
| 434 | issues: [], |
| 435 | errorCount: 0, |
| 436 | warningCount: 0, |
| 437 | infoCount: 0, |
| 438 | issueCount: 0, |
| 439 | }), |
| 440 | null, |
| 441 | 2, |
| 442 | ), |
| 443 | ); |
| 444 | } else { |
| 445 | console.error(`${c.error("✗")} ${message}`); |
| 446 | } |
| 447 | process.exit(1); |
| 448 | } |
| 449 | |
| 450 | function parseAt(value: unknown): number[] | undefined { |
| 451 | if (!value) return undefined; |
no test coverage detected