@@ -23,55 +23,49 @@ const FullReport = require('./lib/FullReport');
2323 * @returns {FullReport }
2424 */
2525function processFile ( sourceDir , data , lcov , config ) {
26- const lines = data . split ( / \r ? \n / ) ;
26+ /** @type { import("./lib/CoverageFile")|null } */
2727 let currentCoverageFile = null ;
2828
29- for ( let i = 0 , l = lines . length ; i < l ; i ++ ) {
29+ const lines = data . split ( / \r ? \n / ) ;
30+
31+ for ( let i = 0 ; i < lines . length ; i += 1 ) {
3032 const line = lines [ i ] ;
33+
3134 if ( line === 'end_of_record' || line === '' ) {
3235 currentCoverageFile = null ;
3336 continue ;
3437 }
3538
36- const prefixSplit = line . split ( ':' ) ;
37- const prefix = prefixSplit [ 0 ] ;
39+ const [ prefix , ... suffixParts ] = line . split ( ':' ) ;
40+ const suffix = suffixParts . join ( ':' ) ;
3841
3942 switch ( prefix ) {
4043 case 'SF' : {
41- let sourceFileNameParts = prefixSplit ;
44+ let sourceFilePath = suffix ;
4245
4346 if ( config . prependSourceFiles ) {
4447 const fullFilePathName = path . normalize (
45- path . join (
46- sourceDir ,
47- config . prependPathFix ,
48- prefixSplit . slice ( 1 ) . join ( ':' )
49- )
48+ path . join ( sourceDir , config . prependPathFix , sourceFilePath )
5049 ) ;
5150
5251 const rootRelPathName = path . relative (
5352 process . cwd ( ) ,
5453 fullFilePathName
5554 ) ;
5655
57- sourceFileNameParts = [ prefix ] . concat (
58- ( './' + rootRelPathName ) . split ( ':' )
59- ) ;
56+ sourceFilePath = './' + rootRelPathName ;
6057 }
6158
62- // If the filepath contains a ':', we want to preserve it.
63- currentCoverageFile = lcov . addCoverageFile (
64- sourceFileNameParts . slice ( 1 ) . join ( ':' )
65- ) ;
66-
59+ currentCoverageFile = lcov . addCoverageFile ( sourceFilePath ) ;
6760 break ;
6861 }
62+
6963 case 'DA' :
70- currentCoverageFile . parseDA ( prefixSplit [ 1 ] ) ;
64+ currentCoverageFile . parseDA ( suffix ) ;
7165 break ;
7266
7367 case 'BRDA' :
74- currentCoverageFile . parseBRDA ( prefixSplit [ 1 ] ) ;
68+ currentCoverageFile . parseBRDA ( suffix ) ;
7569 break ;
7670
7771 default :
0 commit comments