From 9192e6299547bfb18106af22363f1d10ecfa6ec6 Mon Sep 17 00:00:00 2001 From: Ade Attwood Date: Tue, 13 Jun 2023 14:16:47 +0100 Subject: [PATCH] feat: update the coverage to exclude "normal" lines This will now exclude lines that are not added or edited in the diff. They are lines that are included in the diff context but will still count towards the coverage percentage. You now get a more accurate coverage percentage from what you have edited in the diff. --- src/report.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/report.ts b/src/report.ts index 923e2ce..dad386e 100644 --- a/src/report.ts +++ b/src/report.ts @@ -54,7 +54,14 @@ export const printReport = (diff: Diff[], coverage: any) => { if (change.type === "del") { continue; } + const line = change.ln || change.ln2; + + if (change.type === "normal") { + console.log(line.toString().padStart(4, " "), "\x1b[0m", change.content.substring(1), "\x1b[0m"); + continue; + } + let color = "\x1b[0m"; if (typeof fileCoverage[line] !== "undefined") { color = fileCoverage[line] > 0 ? "\x1b[32m" : "\x1b[31m";