Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Purge source-map cache before reporting if cache is disabled. #1080

Merged
merged 2 commits into from Apr 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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) {
JaKXz marked this conversation as resolved.
Show resolved Hide resolved
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.