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 config values to hash salt #988

Merged
merged 4 commits into from Feb 27, 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
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -94,7 +94,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
@@ -1,8 +1,30 @@
'use strict'

function getInvalidatingOptions (config) {
return [
taye marked this conversation as resolved.
Show resolved Hide resolved
'compact',
'esModules',
'ignoreClassMethods',
'instrument',
coreyfarrell marked this conversation as resolved.
Show resolved Hide resolved
'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)
})
}
}