1- " use strict" ;
1+ ' use strict' ;
22
33// src/coverage-reporter.cts
4- var fs = require ( "fs" ) ;
5- var { ReportBase } = require ( "istanbul-lib-report" ) ;
4+ var fs = require ( 'fs' ) ;
5+ var { ReportBase } = require ( 'istanbul-lib-report' ) ;
6+
67function isFull ( metrics ) {
78 return metrics . statements . pct === 100 && metrics . branches . pct === 100 && metrics . functions . pct === 100 && metrics . lines . pct === 100 ;
89}
@@ -38,7 +39,7 @@ function getUncoveredLines(node) {
3839 } , [ ] ) ;
3940 return ranges ;
4041}
41- var headers = [ " Statements" , " Branches" , " Functions" , " Lines" ] ;
42+ var headers = [ ' Statements' , ' Branches' , ' Functions' , ' Lines' ] ;
4243module . exports = class GithubActionsCoverageReporter extends ReportBase {
4344 skipEmpty ;
4445 skipFull ;
@@ -52,20 +53,20 @@ module.exports = class GithubActionsCoverageReporter extends ReportBase {
5253 }
5354 onStart ( _node , context ) {
5455 if ( ! process . env . GITHUB_STEP_SUMMARY ) {
55- console . log ( " Reporter not being executed in Github Actions environment" ) ;
56+ console . log ( ' Reporter not being executed in Github Actions environment' ) ;
5657 return ;
5758 }
58- this . cw = fs . createWriteStream ( process . env . GITHUB_STEP_SUMMARY , { encoding : " utf-8" , flags : "a" } ) ;
59+ this . cw = fs . createWriteStream ( process . env . GITHUB_STEP_SUMMARY , { encoding : ' utf-8' , flags : 'a' } ) ;
5960 this . watermarks = context . watermarks ;
60- this . cw . write ( " <h3>Test Coverage</h3>" ) ;
61- this . cw . write ( " <table><thead><tr>" ) ;
62- for ( const heading of [ " File" , ...headers , " Uncovered Lines" ] ) {
61+ this . cw . write ( ' <h3>Test Coverage</h3>' ) ;
62+ this . cw . write ( ' <table><thead><tr>' ) ;
63+ for ( const heading of [ ' File' , ...headers , ' Uncovered Lines' ] ) {
6364 this . cw . write ( `<th>${ heading } </th>` ) ;
6465 }
65- this . cw . write ( " </tr></thead><tbody>" ) ;
66+ this . cw . write ( ' </tr></thead><tbody>' ) ;
6667 }
6768 onSummary ( node ) {
68- const nodeName = node . getRelativeName ( ) || " All Files" ;
69+ const nodeName = node . getRelativeName ( ) || ' All Files' ;
6970 const rawMetrics = node . getCoverageSummary ( false ) ;
7071 const isEmpty = rawMetrics . isEmpty ( ) ;
7172 if ( this . skipEmpty && isEmpty ) {
@@ -102,26 +103,26 @@ module.exports = class GithubActionsCoverageReporter extends ReportBase {
102103 for ( const fileName of fileNames ) {
103104 const metrics = this . results [ fileName ] ;
104105 this . cw . write ( `<tr><td><code>${ fileName } </code></td>` ) ;
105- this . cw . write ( this . formatter ( metrics . statements , " statements" ) ) ;
106- this . cw . write ( this . formatter ( metrics . branches , " branches" ) ) ;
107- this . cw . write ( this . formatter ( metrics . functions , " functions" ) ) ;
108- this . cw . write ( this . formatter ( metrics . lines , " lines" ) ) ;
106+ this . cw . write ( this . formatter ( metrics . statements , ' statements' ) ) ;
107+ this . cw . write ( this . formatter ( metrics . branches , ' branches' ) ) ;
108+ this . cw . write ( this . formatter ( metrics . functions , ' functions' ) ) ;
109+ this . cw . write ( this . formatter ( metrics . lines , ' lines' ) ) ;
109110 if ( metrics . uncoveredLines . length > 0 ) {
110- this . cw . write ( " <td><details><summary>Expand</summary><ul>" ) ;
111+ this . cw . write ( ' <td><details><summary>Expand</summary><ul>' ) ;
111112 for ( const range of metrics . uncoveredLines ) {
112113 if ( range . length === 1 ) {
113114 this . cw . write ( `<li>${ range [ 0 ] } </li>` ) ;
114115 } else {
115116 this . cw . write ( `<li>${ range [ 0 ] } -${ range [ 1 ] } </li>` ) ;
116117 }
117118 }
118- this . cw . write ( " </ul></details></td>" ) ;
119+ this . cw . write ( ' </ul></details></td>' ) ;
119120 } else {
120- this . cw . write ( " <td></td>" ) ;
121+ this . cw . write ( ' <td></td>' ) ;
121122 }
122- this . cw . write ( " </tr>" ) ;
123+ this . cw . write ( ' </tr>' ) ;
123124 }
124- this . cw . write ( " </tbody></table>" ) ;
125+ this . cw . write ( ' </tbody></table>' ) ;
125126 this . cw . close ( ) ;
126127 }
127128} ;
0 commit comments