File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,8 @@ function NYC (config) {
84
84
85
85
this . processInfo = new ProcessInfo ( config && config . _processInfo )
86
86
this . rootId = this . processInfo . root || this . generateUniqueID ( )
87
+ this . instrument = config . instrument
88
+ this . all = config . all
87
89
}
88
90
89
91
NYC . prototype . _createTransform = function ( ext ) {
@@ -166,6 +168,9 @@ NYC.prototype.addAllFiles = function () {
166
168
_this . addFile ( filename )
167
169
var coverage = coverageFinder ( )
168
170
var lastCoverage = _this . instrumenter ( ) . lastFileCoverage ( )
171
+ if ( lastCoverage ) {
172
+ filename = lastCoverage . path
173
+ }
169
174
if ( lastCoverage && _this . exclude . shouldInstrument ( filename ) ) {
170
175
coverage [ filename ] = lastCoverage
171
176
}
@@ -233,7 +238,7 @@ NYC.prototype.walkAllFiles = function (dir, visitor) {
233
238
}
234
239
235
240
NYC . prototype . _maybeInstrumentSource = function ( code , filename , relFile ) {
236
- var instrument = this . exclude . shouldInstrument ( filename , relFile )
241
+ var instrument = ( ! this . instrument && this . all ) || this . exclude . shouldInstrument ( filename , relFile )
237
242
if ( ! instrument ) {
238
243
return null
239
244
}
Original file line number Diff line number Diff line change
1
+ var FileCoverage = require ( 'istanbul-lib-coverage' ) . classes . FileCoverage
2
+ var readInitialCoverage = require ( 'istanbul-lib-instrument' ) . readInitialCoverage
3
+
1
4
function NOOP ( ) {
2
5
return {
3
6
instrumentSync : function ( code ) {
7
+ var extracted = readInitialCoverage ( code )
8
+ if ( extracted ) {
9
+ this . fileCoverage = new FileCoverage ( extracted . coverageData )
10
+ } else {
11
+ this . fileCoverage = null
12
+ }
4
13
return code
5
14
} ,
6
15
lastFileCoverage : function ( ) {
7
- return null
16
+ return this . fileCoverage
8
17
}
9
18
}
10
19
}
You can’t perform that action at this time.
0 commit comments