@@ -83,13 +83,17 @@ function NYC (config) {
8383
8484 this . processInfo = new ProcessInfo ( config && config . _processInfo )
8585 this . rootId = this . processInfo . root || this . generateUniqueID ( )
86+
87+ this . hashCache = { }
8688}
8789
8890NYC . prototype . _createTransform = function ( ext ) {
91+ var _this = this
8992 var opts = {
9093 salt : Hash . salt ,
9194 hash : function ( code , metadata , salt ) {
9295 var hash = Hash ( code , metadata . filename )
96+ _this . hashCache [ metadata . filename ] = hash
9397 return hash
9498 } ,
9599 cacheDir : this . cacheDirectory ,
@@ -267,7 +271,7 @@ NYC.prototype._transformFactory = function (cacheDir) {
267271 var filename = metadata . filename
268272 var sourceMap = null
269273
270- if ( _this . _sourceMap ) sourceMap = _this . sourceMaps . extractAndRegister ( code , filename )
274+ if ( _this . _sourceMap ) sourceMap = _this . sourceMaps . extractAndRegister ( code , filename , hash )
271275
272276 try {
273277 instrumented = instrumenter . instrumentSync ( code , filename , sourceMap )
@@ -365,8 +369,8 @@ NYC.prototype.writeCoverageFile = function () {
365369
366370 if ( this . cache ) {
367371 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 ]
370374 }
371375 } , this )
372376 } else {
0 commit comments