@@ -12,7 +12,6 @@ const {
12
12
includeAllFiles
13
13
} = require ( './task-utils' )
14
14
const { fixSourcePaths } = require ( './support-utils' )
15
- const { removePlaceholders } = require ( './common-utils' )
16
15
17
16
const debug = require ( 'debug' ) ( 'code-coverage' )
18
17
@@ -30,6 +29,7 @@ const pkg = existsSync(pkgFilename)
30
29
const scripts = pkg . scripts || { }
31
30
const DEFAULT_CUSTOM_COVERAGE_SCRIPT_NAME = 'coverage:report'
32
31
const customNycReportScript = scripts [ DEFAULT_CUSTOM_COVERAGE_SCRIPT_NAME ]
32
+ let coverageMap = istanbul . createCoverageMap ( { } )
33
33
34
34
const nycReportOptions = ( function getNycOption ( ) {
35
35
// https://github.com/istanbuljs/nyc#common-configuration-options
@@ -122,7 +122,7 @@ const tasks = {
122
122
resetCoverage ( { isInteractive } ) {
123
123
if ( isInteractive ) {
124
124
debug ( 'reset code coverage in interactive mode' )
125
- const coverageMap = istanbul . createCoverageMap ( { } )
125
+ coverageMap = istanbul . createCoverageMap ( { } )
126
126
saveCoverage ( coverageMap )
127
127
}
128
128
/*
@@ -148,21 +148,7 @@ const tasks = {
148
148
149
149
fixSourcePaths ( coverage )
150
150
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 )
163
151
coverageMap . merge ( coverage )
164
- saveCoverage ( coverageMap )
165
- debug ( 'wrote coverage file %s' , nycFilename )
166
152
167
153
return null
168
154
} ,
@@ -172,6 +158,7 @@ const tasks = {
172
158
* NPM script to generate HTML report
173
159
*/
174
160
coverageReport ( ) {
161
+ saveCoverage ( coverageMap )
175
162
if ( ! existsSync ( nycFilename ) ) {
176
163
console . warn ( 'Cannot find coverage file %s' , nycFilename )
177
164
console . warn ( 'Skipping coverage report' )
0 commit comments