(lines: string[])
| 21 | } |
| 22 | |
| 23 | const processResult = (lines: string[]) => { |
| 24 | // Skip results in which only the file path was kept |
| 25 | const resultPath = lines[0]; |
| 26 | const resultContent = lines.slice(1); |
| 27 | if (resultContent.length === 0) { |
| 28 | return; |
| 29 | } |
| 30 | |
| 31 | // Add path |
| 32 | keepLines.push(resultPath); |
| 33 | |
| 34 | // Find the minimum indentation of content lines |
| 35 | let minIndent = Infinity; |
| 36 | for (const line of resultContent) { |
| 37 | const indent = countLeadingSpaces(line); |
| 38 | if (indent < minIndent) { |
| 39 | minIndent = indent; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | // Make all lines line up to 2-space indent |
| 44 | const changeIndentBy = 2 - minIndent; |
| 45 | if (changeIndentBy === 0) { |
| 46 | keepLines.push(...resultContent); |
| 47 | } else if (changeIndentBy < 0) { |
| 48 | keepLines.push( |
| 49 | ...resultContent.map((line) => line.substring(-changeIndentBy)), |
| 50 | ); |
| 51 | } else { |
| 52 | keepLines.push( |
| 53 | ...resultContent.map((line) => " ".repeat(changeIndentBy) + line), |
| 54 | ); |
| 55 | } |
| 56 | }; |
| 57 | |
| 58 | let resultLines: string[] = []; |
| 59 | for (const line of results.split("\n").filter((l) => !!l)) { |
no test coverage detected