(state: State, pointer: Doc.AnsiDoc)
| 66 | const NEWLINE_REGEX = /\r?\n/ |
| 67 | |
| 68 | function renderError(state: State, pointer: Doc.AnsiDoc) { |
| 69 | return Option.match(state.error, { |
| 70 | onNone: () => Doc.empty, |
| 71 | onSome: (error) => |
| 72 | Arr.match(error.split(NEWLINE_REGEX), { |
| 73 | onEmpty: () => Doc.empty, |
| 74 | onNonEmpty: (errorLines) => { |
| 75 | const annotateLine = (line: string): Doc.AnsiDoc => |
| 76 | Doc.annotate(Doc.text(line), Ansi.combine(Ansi.italicized, Ansi.red)) |
| 77 | const prefix = Doc.cat(Doc.annotate(pointer, Ansi.red), Doc.space) |
| 78 | const lines = Arr.map(errorLines, (str) => annotateLine(str)) |
| 79 | return Doc.cursorSavePosition.pipe( |
| 80 | Doc.cat(Doc.hardLine), |
| 81 | Doc.cat(prefix), |
| 82 | Doc.cat(Doc.align(Doc.vsep(lines))), |
| 83 | Doc.cat(Doc.cursorRestorePosition) |
| 84 | ) |
| 85 | } |
| 86 | }) |
| 87 | }) |
| 88 | } |
| 89 | |
| 90 | function renderOutput( |
| 91 | state: State, |
no test coverage detected
searching dependent graphs…