Skip to content

Commit

Permalink
fix: Purge source-map cache before reporting if cache is disabled. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyfarrell committed Apr 24, 2019
1 parent 132a074 commit 3d9eaa4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 22 deletions.
1 change: 1 addition & 0 deletions bin/nyc.js
Expand Up @@ -67,6 +67,7 @@ if ([

nyc.writeProcessIndex()

nyc.maybePurgeSourceMapCache()
if (argv.checkCoverage) {
nyc.checkCoverage({
lines: argv.lines,
Expand Down
6 changes: 6 additions & 0 deletions index.js
Expand Up @@ -236,6 +236,12 @@ class NYC {
return this._transform(code, filename)
}

maybePurgeSourceMapCache () {
if (!this.cache) {
this.sourceMaps.purgeCache()
}
}

_transformFactory (cacheDir) {
const instrumenter = this.instrumenter()
let instrumented
Expand Down
8 changes: 6 additions & 2 deletions lib/source-maps.js
Expand Up @@ -4,12 +4,16 @@ const libSourceMaps = require('istanbul-lib-source-maps')
const fs = require('fs')
const path = require('path')

const sourceMapCache = libSourceMaps.createSourceMapStore()
function SourceMaps (opts) {
this.cache = opts.cache
this.cacheDirectory = opts.cacheDirectory
this.loadedMaps = {}
this._sourceMapCache = sourceMapCache
this._sourceMapCache = libSourceMaps.createSourceMapStore()
}

SourceMaps.prototype.purgeCache = function () {
this._sourceMapCache = libSourceMaps.createSourceMapStore()
this.loadedMaps = {}
}

SourceMaps.prototype.extractAndRegister = function (code, filename, hash) {
Expand Down
20 changes: 0 additions & 20 deletions test/source-maps.js

This file was deleted.

0 comments on commit 3d9eaa4

Please sign in to comment.