Skip to content

Commit 5ba1c0c

Browse files
added emojies
1 parent 8633318 commit 5ba1c0c

File tree

2 files changed

+14
-24
lines changed

2 files changed

+14
-24
lines changed

dist/main.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6024,6 +6024,11 @@ function uncovered(file, options) {
60246024
.join(", ");
60256025
}
60266026

6027+
const renderEmoji = pdiff => {
6028+
if (pdiff < 0) return "🔴";
6029+
if (pdiff > 0) return "🟢";
6030+
};
6031+
60276032
/**
60286033
* Github comment for monorepo
60296034
* @param {Array<{packageName, lcovPath}>} lcovArrayForMonorepo
@@ -6046,17 +6051,7 @@ function commentForMonorepo(
60466051
const plus = pdiff > 0 ? "+" : "";
60476052
const arrow = pdiff === 0 ? "" : pdiff < 0 ? "▾" : "▴";
60486053

6049-
const getColor = () => {
6050-
if (pdiff === 0) return 'inherit';
6051-
if (pdiff < 0) return 'red';
6052-
if (pdiff > 0) return 'green';
6053-
};
6054-
6055-
const thArrow = `<span style="color:${getColor()};"}>${arrow}</span>`;
6056-
const thPlus = `<span style="color:${getColor()};"}>${plus}</span>`;
6057-
const thDiff = `<span style="color:${getColor()};"}>${pdiff.toFixed(2)}</span>`;
6058-
6059-
const pdiffHtml = baseLcov ? th(thArrow, " ", thPlus, thDiff, "%") : "";
6054+
const pdiffHtml = baseLcov ? th(renderEmoji(pdiff), " ", arrow, " ", plus, pdiff.toFixed(2), "%</span>") : "";
60606055

60616056
return `${table(
60626057
tbody(
@@ -6090,7 +6085,7 @@ function comment(lcov, before, options) {
60906085
const plus = pdiff > 0 ? "+" : "";
60916086
const arrow = pdiff === 0 ? "" : pdiff < 0 ? "▾" : "▴";
60926087

6093-
const pdiffHtml = before ? th(arrow, " ", plus, pdiff.toFixed(2), "%") : "";
6088+
const pdiffHtml = before ? th(renderEmoji(pdiff), " ", arrow, " ", plus, pdiff.toFixed(2), "%</span>") : "";
60946089

60956090
return fragment(
60966091
`Coverage after merging ${b(options.head)} into ${b(

src/comment.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import { details, summary, b, fragment, table, tbody, tr, th } from "./html";
22
import { percentage } from "./lcov";
33
import { tabulate } from "./tabulate";
44

5+
const renderEmoji = pdiff => {
6+
if (pdiff < 0) return "🔴";
7+
if (pdiff > 0) return "🟢";
8+
};
9+
510
/**
611
* Github comment for monorepo
712
* @param {Array<{packageName, lcovPath}>} lcovArrayForMonorepo
@@ -24,17 +29,7 @@ export function commentForMonorepo(
2429
const plus = pdiff > 0 ? "+" : "";
2530
const arrow = pdiff === 0 ? "" : pdiff < 0 ? "▾" : "▴";
2631

27-
const getColor = () => {
28-
if (pdiff === 0) return "color:inherit;";
29-
if (pdiff < 0) return "color:red;";
30-
if (pdiff > 0) return "color:green;";
31-
};
32-
33-
const thArrow = `<span style=${getColor()}>${arrow}</span>`;
34-
const thPlus = `<span style=${getColor()}>${plus}</span>`;
35-
const thDiff = `<span style=${getColor()}>${pdiff.toFixed(2)}</span>`;
36-
37-
const pdiffHtml = baseLcov ? th(thArrow, " ", thPlus, thDiff, "%") : "";
32+
const pdiffHtml = baseLcov ? th(renderEmoji(pdiff), " ", arrow, " ", plus, pdiff.toFixed(2), "%</span>") : "";
3833

3934
return `${table(
4035
tbody(
@@ -68,7 +63,7 @@ export function comment(lcov, before, options) {
6863
const plus = pdiff > 0 ? "+" : "";
6964
const arrow = pdiff === 0 ? "" : pdiff < 0 ? "▾" : "▴";
7065

71-
const pdiffHtml = before ? th(arrow, " ", plus, pdiff.toFixed(2), "%") : "";
66+
const pdiffHtml = before ? th(renderEmoji(pdiff), " ", arrow, " ", plus, pdiff.toFixed(2), "%</span>") : "";
7267

7368
return fragment(
7469
`Coverage after merging ${b(options.head)} into ${b(

0 commit comments

Comments
 (0)