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: add a feature which allows us to bust the cache when breaking changes are introduced #394

Merged
merged 3 commits into from
Sep 15, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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