@@ -39,6 +39,7 @@ if (/index\.covered\.js$/.test(__filename)) {
39
39
40
40
function NYC ( config ) {
41
41
config = config || { }
42
+ this . config = config
42
43
43
44
this . subprocessBin = config . subprocessBin || path . resolve ( __dirname , './bin/nyc.js' )
44
45
this . _tempDirectory = config . tempDirectory || './.nyc_output'
@@ -84,8 +85,6 @@ function NYC (config) {
84
85
85
86
this . processInfo = new ProcessInfo ( config && config . _processInfo )
86
87
this . rootId = this . processInfo . root || this . generateUniqueID ( )
87
- this . instrument = config . instrument
88
- this . all = config . all
89
88
}
90
89
91
90
NYC . prototype . _createTransform = function ( ext ) {
@@ -128,7 +127,9 @@ NYC.prototype.instrumenter = function () {
128
127
}
129
128
130
129
NYC . prototype . _createInstrumenter = function ( ) {
131
- return this . _instrumenterLib ( this . cwd )
130
+ return this . _instrumenterLib ( this . cwd , {
131
+ produceSourceMap : this . config . produceSourceMap
132
+ } )
132
133
}
133
134
134
135
NYC . prototype . addFile = function ( filename ) {
@@ -261,14 +262,15 @@ NYC.prototype._transformFactory = function (cacheDir) {
261
262
262
263
return function ( code , metadata , hash ) {
263
264
var filename = metadata . filename
265
+ var sourceMap = null
264
266
265
- if ( _this . _sourceMap ) _this . _handleSourceMap ( cacheDir , code , hash , filename )
267
+ if ( _this . _sourceMap ) sourceMap = _this . _handleSourceMap ( cacheDir , code , hash , filename )
266
268
267
269
try {
268
- instrumented = instrumenter . instrumentSync ( code , filename )
270
+ instrumented = instrumenter . instrumentSync ( code , filename , sourceMap )
269
271
} catch ( e ) {
270
272
// don't fail external tests due to instrumentation bugs.
271
- console . warn ( 'failed to instrument' , filename , 'with error:' , e . message )
273
+ console . warn ( 'failed to instrument' , filename , 'with error:' , e . stack )
272
274
instrumented = code
273
275
}
274
276
@@ -290,6 +292,7 @@ NYC.prototype._handleSourceMap = function (cacheDir, code, hash, filename) {
290
292
this . sourceMapCache . registerMap ( filename , sourceMap . sourcemap )
291
293
}
292
294
}
295
+ return sourceMap
293
296
}
294
297
295
298
NYC . prototype . _handleJs = function ( code , filename ) {
0 commit comments