@@ -18,6 +18,7 @@ const { values } = parseArgs({
1818 options : {
1919 'code-only' : { type : 'boolean' , default : false } ,
2020 'type-only' : { type : 'boolean' , default : false } ,
21+ summary : { type : 'boolean' , default : false } ,
2122 } ,
2223 strict : false ,
2324} )
@@ -26,7 +27,7 @@ printHeader('Test Coverage')
2627
2728// Run vitest with coverage enabled, capturing output
2829// Filter out custom flags that vitest doesn't understand
29- const customFlags = [ '--code-only' , '--type-only' ]
30+ const customFlags = [ '--code-only' , '--type-only' , '--summary' ]
3031const vitestArgs = [
3132 'exec' ,
3233 'vitest' ,
8384 const testSummaryMatch = output . match (
8485 / 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 ] * / ,
8586 )
86- if ( testSummaryMatch ) {
87+ if ( ! values . summary && testSummaryMatch ) {
8788 console . log ( )
8889 console . log ( testSummaryMatch [ 0 ] )
8990 console . log ( )
@@ -96,13 +97,15 @@ try {
9697 const allFilesMatch = output . match ( / A l l f i l e s \s + \| \s + ( [ \d . ] + ) \s + \| [ ^ \n ] * / )
9798
9899 if ( coverageHeaderMatch && allFilesMatch ) {
99- console . log ( ' % Coverage report from v8' )
100- console . log ( coverageHeaderMatch [ 1 ] )
101- console . log ( coverageHeaderMatch [ 2 ] )
102- console . log ( coverageHeaderMatch [ 1 ] )
103- console . log ( allFilesMatch [ 0 ] )
104- console . log ( coverageHeaderMatch [ 1 ] )
105- console . log ( )
100+ if ( ! values . summary ) {
101+ console . log ( ' % Coverage report from v8' )
102+ console . log ( coverageHeaderMatch [ 1 ] )
103+ console . log ( coverageHeaderMatch [ 2 ] )
104+ console . log ( coverageHeaderMatch [ 1 ] )
105+ console . log ( allFilesMatch [ 0 ] )
106+ console . log ( coverageHeaderMatch [ 1 ] )
107+ console . log ( )
108+ }
106109
107110 const codeCoveragePercent = Number . parseFloat ( allFilesMatch [ 1 ] )
108111 console . log ( ' Coverage Summary' )
@@ -153,20 +156,22 @@ try {
153156 )
154157
155158 // Display output
156- if ( testSummaryMatch ) {
159+ if ( ! values . summary && testSummaryMatch ) {
157160 console . log ( )
158161 console . log ( testSummaryMatch [ 0 ] )
159162 console . log ( )
160163 }
161164
162165 if ( coverageHeaderMatch && allFilesMatch ) {
163- console . log ( ' % Coverage report from v8' )
164- console . log ( coverageHeaderMatch [ 1 ] )
165- console . log ( coverageHeaderMatch [ 2 ] )
166- console . log ( coverageHeaderMatch [ 1 ] )
167- console . log ( allFilesMatch [ 0 ] )
168- console . log ( coverageHeaderMatch [ 1 ] )
169- console . log ( )
166+ if ( ! values . summary ) {
167+ console . log ( ' % Coverage report from v8' )
168+ console . log ( coverageHeaderMatch [ 1 ] )
169+ console . log ( coverageHeaderMatch [ 2 ] )
170+ console . log ( coverageHeaderMatch [ 1 ] )
171+ console . log ( allFilesMatch [ 0 ] )
172+ console . log ( coverageHeaderMatch [ 1 ] )
173+ console . log ( )
174+ }
170175
171176 // Display cumulative summary
172177 if ( typeCoverageMatch ) {
0 commit comments