@@ -6024,11 +6024,28 @@ function uncovered(file, options) {
60246024 . join ( ", " ) ;
60256025}
60266026
6027+ /**
6028+ * Compares two arrays of objects and returns with unique lines update
6029+ * @param {number } pdiff value from diff percentage
6030+ * @returns {string } emoji string for negative/positive pdiff
6031+ */
60276032const renderEmoji = pdiff => {
6028- if ( pdiff < 0 ) return "🔴" ;
6029- if ( pdiff >= 0 ) return "🟢" ;
6033+ if ( pdiff < 0 ) return "🔴" ;
6034+ if ( pdiff >= 0 ) return "🟢" ;
60306035} ;
60316036
6037+ /**
6038+ * Compares two arrays of objects and returns with unique lines update
6039+ * @param {Array } otherArray
6040+ * @returns {Function } function with filtering non original lines
6041+ */
6042+ const comparer = otherArray => current =>
6043+ otherArray . filter (
6044+ other =>
6045+ other . lines . found === current . lines . found &&
6046+ other . lines . hit === current . lines . hit ,
6047+ ) . length === 0 ;
6048+
60326049/**
60336050 * Github comment for monorepo
60346051 * @param {Array<{packageName, lcovPath}> } lcovArrayForMonorepo
@@ -6052,6 +6069,13 @@ function commentForMonorepo(
60526069 const arrow = pdiff === 0 ? "" : pdiff < 0 ? "▾" : "▴" ;
60536070
60546071 const pdiffHtml = baseLcov ? th ( renderEmoji ( pdiff ) , " " , arrow , " " , plus , pdiff . toFixed ( 2 ) , "%" ) : "" ;
6072+ let report = lcovObj . lcov ;
6073+
6074+ if ( baseLcov ) {
6075+ const onlyInLcov = lcovObj . lcov . filter ( comparer ( baseLcov ) ) ;
6076+ const onlyInBefore = baseLcov . filter ( comparer ( lcovObj . lcov ) ) ;
6077+ report = onlyInBefore . concat ( onlyInLcov ) ;
6078+ }
60556079
60566080 return `${ table (
60576081 tbody (
@@ -6063,7 +6087,7 @@ function commentForMonorepo(
60636087 ) ,
60646088 ) } \n\n ${ details (
60656089 summary ( "Coverage Report" ) ,
6066- tabulate ( lcovObj . lcov , options ) ,
6090+ tabulate ( report , options ) ,
60676091 ) } <br/>`;
60686092 } ) ;
60696093
@@ -6078,7 +6102,7 @@ function commentForMonorepo(
60786102 * @param {raw lcov } lcov
60796103 * @param {* } options
60806104 */
6081- function comment ( lcov , before , options ) {
6105+ async function comment ( lcov , before , options ) {
60826106 const pbefore = before ? percentage ( before ) : 0 ;
60836107 const pafter = before ? percentage ( lcov ) : 0 ;
60846108 const pdiff = pafter - pbefore ;
@@ -6087,14 +6111,13 @@ function comment(lcov, before, options) {
60876111
60886112 const pdiffHtml = before ? th ( renderEmoji ( pdiff ) , " " , arrow , " " , plus , pdiff . toFixed ( 2 ) , "%" ) : "" ;
60896113
6090- let report = lcov ;
6091- if ( before ) {
6092- const uniqueResultBase = before . filter ( obj => ! lcov . some ( obj2 => obj . lines === obj2 . lines ) ) ;
6093- const uniqueResultLcov = lcov . filter ( obj => ! before . some ( obj2 => obj . lines === obj2 . lines ) ) ;
6114+ let report = lcov ;
60946115
6095- report = uniqueResultBase . concat ( uniqueResultLcov ) ;
6096- console . log ( report ) ;
6097- }
6116+ if ( before ) {
6117+ const onlyInLcov = lcov . filter ( comparer ( before ) ) ;
6118+ const onlyInBefore = before . filter ( comparer ( lcov ) ) ;
6119+ report = onlyInBefore . concat ( onlyInLcov ) ;
6120+ }
60986121
60996122 return fragment (
61006123 `Coverage after merging ${ b ( options . head ) } into ${ b (
@@ -6320,7 +6343,7 @@ async function main() {
63206343 commit : context . payload . pull_request . head . sha ,
63216344 prefix : `${ process . env . GITHUB_WORKSPACE } /` ,
63226345 head : context . payload . pull_request . head . ref ,
6323- base : context . payload . pull_request . base . ref ,
6346+ base : context . payload . pull_request . base . ref
63246347 } ;
63256348
63266349 const lcov = ! monorepoBasePath && ( await parse$1 ( raw ) ) ;
0 commit comments