@@ -55,37 +55,34 @@ export async function lcovResultsToAuditOutputs(
5555export async function parseLcovFiles (
5656 results : CoverageResult [ ] ,
5757) : Promise < LCOVRecord [ ] > {
58- const parsedResults = await Promise . all (
59- results . map ( async result => {
60- const resultsPath =
61- typeof result === 'string' ? result : result . resultsPath ;
62- const lcovFileContent = await readTextFile ( resultsPath ) ;
63- if ( lcovFileContent . trim ( ) === '' ) {
64- ui ( ) . logger . warning (
65- `Coverage plugin: Empty lcov report file detected at ${ resultsPath } .` ,
66- ) ;
67- }
68- const parsedRecords = parseLcov ( toUnixNewlines ( lcovFileContent ) ) ;
69- return parsedRecords . map < LCOVRecord > ( record => ( {
70- ...record ,
71- file :
72- typeof result === 'string' || result . pathToProject == null
73- ? record . file
74- : path . join ( result . pathToProject , record . file ) ,
75- } ) ) ;
76- } ) ,
77- ) ;
78- if ( parsedResults . length !== results . length ) {
79- throw new Error ( 'Some provided LCOV results were not valid.' ) ;
80- }
81-
82- const flatResults = parsedResults . flat ( ) ;
58+ const parsedResults = (
59+ await Promise . all (
60+ results . map ( async result => {
61+ const resultsPath =
62+ typeof result === 'string' ? result : result . resultsPath ;
63+ const lcovFileContent = await readTextFile ( resultsPath ) ;
64+ if ( lcovFileContent . trim ( ) === '' ) {
65+ ui ( ) . logger . warning (
66+ `Coverage plugin: Empty lcov report file detected at ${ resultsPath } .` ,
67+ ) ;
68+ }
69+ const parsedRecords = parseLcov ( toUnixNewlines ( lcovFileContent ) ) ;
70+ return parsedRecords . map < LCOVRecord > ( record => ( {
71+ ...record ,
72+ file :
73+ typeof result === 'string' || result . pathToProject == null
74+ ? record . file
75+ : path . join ( result . pathToProject , record . file ) ,
76+ } ) ) ;
77+ } ) ,
78+ )
79+ ) . flat ( ) ;
8380
84- if ( flatResults . length === 0 ) {
85- throw new Error ( 'All provided results are empty.' ) ;
81+ if ( parsedResults . length === 0 ) {
82+ throw new Error ( 'All provided coverage results are empty.' ) ;
8683 }
8784
88- return flatResults ;
85+ return parsedResults ;
8986}
9087
9188/**
0 commit comments