@@ -12,7 +12,6 @@ const {
1212 includeAllFiles
1313} = require ( './task-utils' )
1414const { fixSourcePaths } = require ( './support-utils' )
15- const { removePlaceholders } = require ( './common-utils' )
1615
1716const debug = require ( 'debug' ) ( 'code-coverage' )
1817
@@ -30,6 +29,7 @@ const pkg = existsSync(pkgFilename)
3029const scripts = pkg . scripts || { }
3130const DEFAULT_CUSTOM_COVERAGE_SCRIPT_NAME = 'coverage:report'
3231const customNycReportScript = scripts [ DEFAULT_CUSTOM_COVERAGE_SCRIPT_NAME ]
32+ let coverageMap = istanbul . createCoverageMap ( { } )
3333
3434const nycReportOptions = ( function getNycOption ( ) {
3535 // https://github.com/istanbuljs/nyc#common-configuration-options
@@ -122,7 +122,7 @@ const tasks = {
122122 resetCoverage ( { isInteractive } ) {
123123 if ( isInteractive ) {
124124 debug ( 'reset code coverage in interactive mode' )
125- const coverageMap = istanbul . createCoverageMap ( { } )
125+ coverageMap = istanbul . createCoverageMap ( { } )
126126 saveCoverage ( coverageMap )
127127 }
128128 /*
@@ -148,21 +148,7 @@ const tasks = {
148148
149149 fixSourcePaths ( coverage )
150150
151- const previousCoverage = existsSync ( nycFilename )
152- ? JSON . parse ( readFileSync ( nycFilename , 'utf8' ) )
153- : { }
154-
155- // previous code coverage object might have placeholder entries
156- // for files that we have not seen yet,
157- // but the user expects to include in the coverage report
158- // the merge function messes up, so we should remove any placeholder entries
159- // and re-insert them again when creating the report
160- removePlaceholders ( previousCoverage )
161-
162- const coverageMap = istanbul . createCoverageMap ( previousCoverage )
163151 coverageMap . merge ( coverage )
164- saveCoverage ( coverageMap )
165- debug ( 'wrote coverage file %s' , nycFilename )
166152
167153 return null
168154 } ,
@@ -172,6 +158,7 @@ const tasks = {
172158 * NPM script to generate HTML report
173159 */
174160 coverageReport ( ) {
161+ saveCoverage ( coverageMap )
175162 if ( ! existsSync ( nycFilename ) ) {
176163 console . warn ( 'Cannot find coverage file %s' , nycFilename )
177164 console . warn ( 'Skipping coverage report' )
0 commit comments