(script: string)
| 41 | }; |
| 42 | |
| 43 | export function parseReplayScriptDetailed(script: string): ParsedReplayScript { |
| 44 | const actions: SessionAction[] = []; |
| 45 | const actionLines: number[] = []; |
| 46 | const lines = script.split(/\r?\n/); |
| 47 | let sawAction = false; |
| 48 | for (const [index, rawLine] of lines.entries()) { |
| 49 | const trimmed = rawLine.trim(); |
| 50 | if (trimmed.length === 0 || trimmed.startsWith('#')) continue; |
| 51 | if (isReplayEnvLine(trimmed)) { |
| 52 | if (sawAction) { |
| 53 | throw new AppError( |
| 54 | 'INVALID_ARGS', |
| 55 | `env directives must precede all actions (line ${index + 1}).`, |
| 56 | ); |
| 57 | } |
| 58 | continue; |
| 59 | } |
| 60 | const parsed = parseReplayScriptLine(rawLine); |
| 61 | if (!parsed) continue; |
| 62 | actions.push(parsed); |
| 63 | actionLines.push(index + 1); |
| 64 | sawAction = true; |
| 65 | } |
| 66 | return { actions, actionLines }; |
| 67 | } |
| 68 | |
| 69 | // fallow-ignore-next-line complexity |
| 70 | export function readReplayScriptMetadata(script: string): ReplayScriptMetadata { |
no test coverage detected