@@ -83,13 +83,17 @@ function NYC (config) {
83
83
84
84
this . processInfo = new ProcessInfo ( config && config . _processInfo )
85
85
this . rootId = this . processInfo . root || this . generateUniqueID ( )
86
+
87
+ this . hashCache = { }
86
88
}
87
89
88
90
NYC . prototype . _createTransform = function ( ext ) {
91
+ var _this = this
89
92
var opts = {
90
93
salt : Hash . salt ,
91
94
hash : function ( code , metadata , salt ) {
92
95
var hash = Hash ( code , metadata . filename )
96
+ _this . hashCache [ metadata . filename ] = hash
93
97
return hash
94
98
} ,
95
99
cacheDir : this . cacheDirectory ,
@@ -267,7 +271,7 @@ NYC.prototype._transformFactory = function (cacheDir) {
267
271
var filename = metadata . filename
268
272
var sourceMap = null
269
273
270
- if ( _this . _sourceMap ) sourceMap = _this . sourceMaps . extractAndRegister ( code , filename )
274
+ if ( _this . _sourceMap ) sourceMap = _this . sourceMaps . extractAndRegister ( code , filename , hash )
271
275
272
276
try {
273
277
instrumented = instrumenter . instrumentSync ( code , filename , sourceMap )
@@ -365,8 +369,8 @@ NYC.prototype.writeCoverageFile = function () {
365
369
366
370
if ( this . cache ) {
367
371
Object . keys ( coverage ) . forEach ( function ( absFile ) {
368
- if ( this . sourceMaps . hashCache [ absFile ] && coverage [ absFile ] ) {
369
- coverage [ absFile ] . contentHash = this . sourceMaps . hashCache [ absFile ]
372
+ if ( this . hashCache [ absFile ] && coverage [ absFile ] ) {
373
+ coverage [ absFile ] . contentHash = this . hashCache [ absFile ]
370
374
}
371
375
} , this )
372
376
} else {
0 commit comments