55 * Options:
66 * --code-only Run only code coverage (skip type coverage)
77 * --type-only Run only type coverage (skip code coverage)
8+ * --summary Show only coverage summary (hide detailed output)
89 */
910
1011import path from 'node:path'
@@ -24,16 +25,18 @@ const { values } = parseArgs({
2425 options : {
2526 'code-only' : { type : 'boolean' , default : false } ,
2627 'type-only' : { type : 'boolean' , default : false } ,
28+ summary : { type : 'boolean' , default : false } ,
2729 } ,
2830 strict : false ,
2931 allowPositionals : true ,
3032} )
3133
32- printHeader ( 'Running Coverage' )
34+ printHeader ( 'Test Coverage' )
35+ console . log ( '' )
3336
3437// Run vitest with coverage enabled, capturing output
3538// Filter out custom flags that vitest doesn't understand
36- const customFlags = [ '--code-only' , '--type-only' ]
39+ const customFlags = [ '--code-only' , '--type-only' , '--summary' ]
3740const vitestArgs = [
3841 '-q' ,
3942 'run' ,
99102 const testSummaryMatch = output . match (
100103 / T e s t F i l e s \s + \d + [ ^ \n ] * \n [ \s \S ] * ?D u r a t i o n \s + [ \d . ] + m ? s [ ^ \n ] * / ,
101104 )
102- if ( testSummaryMatch ) {
105+ if ( ! values . summary && testSummaryMatch ) {
103106 console . log ( )
104107 console . log ( testSummaryMatch [ 0 ] )
105108 console . log ( )
@@ -112,13 +115,15 @@ try {
112115 const allFilesMatch = output . match ( / A l l f i l e s \s + \| \s + ( [ \d . ] + ) \s + \| [ ^ \n ] * / )
113116
114117 if ( coverageHeaderMatch && allFilesMatch ) {
115- console . log ( ' % Coverage report from v8' )
116- console . log ( coverageHeaderMatch [ 1 ] )
117- console . log ( coverageHeaderMatch [ 2 ] )
118- console . log ( coverageHeaderMatch [ 1 ] )
119- console . log ( allFilesMatch [ 0 ] )
120- console . log ( coverageHeaderMatch [ 1 ] )
121- console . log ( )
118+ if ( ! values . summary ) {
119+ console . log ( ' % Coverage report from v8' )
120+ console . log ( coverageHeaderMatch [ 1 ] )
121+ console . log ( coverageHeaderMatch [ 2 ] )
122+ console . log ( coverageHeaderMatch [ 1 ] )
123+ console . log ( allFilesMatch [ 0 ] )
124+ console . log ( coverageHeaderMatch [ 1 ] )
125+ console . log ( )
126+ }
122127
123128 const codeCoveragePercent = Number . parseFloat ( allFilesMatch [ 1 ] )
124129 console . log ( ' Coverage Summary' )
@@ -169,20 +174,22 @@ try {
169174 )
170175
171176 // Display output
172- if ( testSummaryMatch ) {
177+ if ( ! values . summary && testSummaryMatch ) {
173178 console . log ( )
174179 console . log ( testSummaryMatch [ 0 ] )
175180 console . log ( )
176181 }
177182
178183 if ( coverageHeaderMatch && allFilesMatch ) {
179- console . log ( ' % Coverage report from v8' )
180- console . log ( coverageHeaderMatch [ 1 ] )
181- console . log ( coverageHeaderMatch [ 2 ] )
182- console . log ( coverageHeaderMatch [ 1 ] )
183- console . log ( allFilesMatch [ 0 ] )
184- console . log ( coverageHeaderMatch [ 1 ] )
185- console . log ( )
184+ if ( ! values . summary ) {
185+ console . log ( ' % Coverage report from v8' )
186+ console . log ( coverageHeaderMatch [ 1 ] )
187+ console . log ( coverageHeaderMatch [ 2 ] )
188+ console . log ( coverageHeaderMatch [ 1 ] )
189+ console . log ( allFilesMatch [ 0 ] )
190+ console . log ( coverageHeaderMatch [ 1 ] )
191+ console . log ( )
192+ }
186193
187194 // Display cumulative summary
188195 if ( typeCoverageMatch ) {
0 commit comments