Skip to content

Commit

Permalink
fix: add a feature which allows us to bust the cache when breaking ch…
Browse files Browse the repository at this point in the history
…anges are introduced (#394)

* fix: add a feature which allows us to bust the cache when breaking changes are introduced

* fix: use package.version for CACHE_VERSION based on @timoxley's review

* fix: ignore line that will never load, because why not
  • Loading branch information
bcoe authored Sep 15, 2016
1 parent 1c2349b commit b7a413a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ var ProcessInfo
try {
ProcessInfo = require('./lib/process.covered.js')
} catch (e) {
/* istanbul ignore next */
ProcessInfo = require('./lib/process.js')
}

// bust cache whenever nyc is upgraded, this prevents
// crashers caused by instrumentation updates.
var CACHE_VERSION = require('./package.json').version

/* istanbul ignore next */
if (/index\.covered\.js$/.test(__filename)) {
require('./lib/self-coverage-helper')
Expand Down Expand Up @@ -83,13 +88,14 @@ function NYC (config) {

NYC.prototype._createTransform = function (ext) {
var _this = this

return cachingTransform({
salt: JSON.stringify({
istanbul: require('istanbul-lib-coverage/package.json').version,
nyc: require('./package.json').version
}),
hash: function (code, metadata, salt) {
var hash = md5hex([code, metadata.filename, salt])
var hash = md5hex([code, metadata.filename, salt]) + '_' + CACHE_VERSION
_this.hashCache[metadata.filename] = hash
return hash
},
Expand Down

0 comments on commit b7a413a

Please sign in to comment.