From 987e4dde8d0998a2cb11f3546d240db4b7a9d9b6 Mon Sep 17 00:00:00 2001 From: Taye Adeyemi Date: Sun, 10 Feb 2019 05:52:57 +0100 Subject: [PATCH 1/4] fix: add config values to hash salt --- index.js | 2 +- lib/hash.js | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 7ffde3216..684780071 100755 --- a/index.js +++ b/index.js @@ -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 diff --git a/lib/hash.js b/lib/hash.js index 918f3773a..339aeae1d 100644 --- a/lib/hash.js +++ b/lib/hash.js @@ -1,8 +1,24 @@ 'use strict' +function getInvalidatingOptions (config) { + return [ + 'instrument', + 'instrumenter', + '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(Object.assign( + { + istanbul: require('istanbul-lib-coverage/package.json').version, + nyc: require('../package.json').version + }, + getInvalidatingOptions(config) + )) + } } From 402bc30a6680a6c8535d6f8ea33edc4eb055d99f Mon Sep 17 00:00:00 2001 From: Taye Adeyemi Date: Sun, 24 Feb 2019 23:12:46 +0100 Subject: [PATCH 2/4] style: add hash salt modules and nycrc props --- lib/hash.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/hash.js b/lib/hash.js index 339aeae1d..39436918e 100644 --- a/lib/hash.js +++ b/lib/hash.js @@ -13,12 +13,12 @@ function getInvalidatingOptions (config) { module.exports = { salt (config) { - return JSON.stringify(Object.assign( - { - istanbul: require('istanbul-lib-coverage/package.json').version, + return JSON.stringify({ + modules: { + 'istanbul-lib-instrument': require('istanbul-lib-coverage/package.json').version, nyc: require('../package.json').version }, - getInvalidatingOptions(config) - )) + nycrc: getInvalidatingOptions(config) + }) } } From ac7a177bf37f39cac97cb291fcb0da82fc5bd96f Mon Sep 17 00:00:00 2001 From: Taye Adeyemi Date: Sun, 24 Feb 2019 23:18:18 +0100 Subject: [PATCH 3/4] fix: add _instrumenterLib options to hash salt --- lib/hash.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/hash.js b/lib/hash.js index 39436918e..90c8f6975 100644 --- a/lib/hash.js +++ b/lib/hash.js @@ -2,8 +2,14 @@ function getInvalidatingOptions (config) { return [ + 'compact', + 'esModules', + 'ignoreClassMethods', 'instrument', 'instrumenter', + 'plugins', + 'preserveComments', + 'produceSourceMap', 'sourceMap' ].reduce((acc, optName) => { acc[optName] = config[optName] From 2858ac92be175fb37fbd5854afa5a79b1427f302 Mon Sep 17 00:00:00 2001 From: Taye Adeyemi Date: Sun, 24 Feb 2019 23:24:56 +0100 Subject: [PATCH 4/4] fix: use istanbul-lib-instrument version instead of istanbul-lib-coverage in hash salt --- lib/hash.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hash.js b/lib/hash.js index 90c8f6975..02f605715 100644 --- a/lib/hash.js +++ b/lib/hash.js @@ -21,7 +21,7 @@ module.exports = { salt (config) { return JSON.stringify({ modules: { - 'istanbul-lib-instrument': require('istanbul-lib-coverage/package.json').version, + 'istanbul-lib-instrument': require('istanbul-lib-instrument/package.json').version, nyc: require('../package.json').version }, nycrc: getInvalidatingOptions(config)