@@ -2,6 +2,11 @@ import { details, summary, b, fragment, table, tbody, tr, th } from "./html";
22import { percentage } from "./lcov" ;
33import { 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