Skip to content

Commit

Permalink
fix: add config values to hash salt (#988)
Browse files Browse the repository at this point in the history
Fixes #522
  • Loading branch information
taye authored and coreyfarrell committed Feb 27, 2019
1 parent 7b5dad5 commit 7ac325d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function NYC (config) {

NYC.prototype._createTransform = function (ext) {
var opts = {
salt: Hash.salt,
salt: Hash.salt(this.config),
hashData: (input, metadata) => [metadata.filename],
onHash: (input, metadata, hash) => {
this.hashCache[metadata.filename] = hash
Expand Down
30 changes: 26 additions & 4 deletions lib/hash.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
'use strict'

function getInvalidatingOptions (config) {
return [
'compact',
'esModules',
'ignoreClassMethods',
'instrument',
'instrumenter',
'plugins',
'preserveComments',
'produceSourceMap',
'sourceMap'
].reduce((acc, optName) => {
acc[optName] = config[optName]
return acc
}, {})
}

module.exports = {
salt: JSON.stringify({
istanbul: require('istanbul-lib-coverage/package.json').version,
nyc: require('../package.json').version
})
salt (config) {
return JSON.stringify({
modules: {
'istanbul-lib-instrument': require('istanbul-lib-instrument/package.json').version,
nyc: require('../package.json').version
},
nycrc: getInvalidatingOptions(config)
})
}
}

0 comments on commit 7ac325d

Please sign in to comment.