From 7ac325d31b0715cda5b058344352a6c76d05e053 Mon Sep 17 00:00:00 2001 From: taye Date: Wed, 27 Feb 2019 15:12:11 +0100 Subject: [PATCH] fix: add config values to hash salt (#988) Fixes #522 --- index.js | 2 +- lib/hash.js | 30 ++++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index d025f462e..dc6a461d9 100755 --- a/index.js +++ b/index.js @@ -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 diff --git a/lib/hash.js b/lib/hash.js index 918f3773a..02f605715 100644 --- a/lib/hash.js +++ b/lib/hash.js @@ -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) + }) + } }