(nextState: State, pointer: Doc.AnsiDoc)
| 95 | } |
| 96 | |
| 97 | function renderError(nextState: State, pointer: Doc.AnsiDoc) { |
| 98 | return Option.match(nextState.error, { |
| 99 | onNone: () => Doc.empty, |
| 100 | onSome: (error) => |
| 101 | Arr.match(error.split(/\r?\n/), { |
| 102 | onEmpty: () => Doc.empty, |
| 103 | onNonEmpty: (errorLines) => { |
| 104 | const annotateLine = (line: string): Doc.AnsiDoc => |
| 105 | Doc.text(line).pipe( |
| 106 | Doc.annotate(Ansi.combine(Ansi.italicized, Ansi.red)) |
| 107 | ) |
| 108 | const prefix = Doc.cat(Doc.annotate(pointer, Ansi.red), Doc.space) |
| 109 | const lines = Arr.map(errorLines, (str) => annotateLine(str)) |
| 110 | return Doc.cursorSavePosition.pipe( |
| 111 | Doc.cat(Doc.hardLine), |
| 112 | Doc.cat(prefix), |
| 113 | Doc.cat(Doc.align(Doc.vsep(lines))), |
| 114 | Doc.cat(Doc.cursorRestorePosition) |
| 115 | ) |
| 116 | } |
| 117 | }) |
| 118 | }) |
| 119 | } |
| 120 | |
| 121 | function renderOutput( |
| 122 | nextState: State, |
no test coverage detected