-
-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Update caching-transform options. (#873)
When updating caching--transform it was missed that the `hash` option has been refactored. This means that two files with identical contents would be treated as identical.
- Loading branch information
1 parent
624a723
commit 52b69ef
Showing
6 changed files
with
50 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,8 @@ | ||
const CACHE_VERSION = require('../package.json').version | ||
const md5hex = require('md5-hex') | ||
const salt = JSON.stringify({ | ||
istanbul: require('istanbul-lib-coverage/package.json').version, | ||
nyc: CACHE_VERSION | ||
}) | ||
'use strict' | ||
|
||
function Hash (code, filename) { | ||
return md5hex([code, filename, salt]) + '_' + CACHE_VERSION | ||
module.exports = { | ||
salt: JSON.stringify({ | ||
istanbul: require('istanbul-lib-coverage/package.json').version, | ||
nyc: require('../package.json').version | ||
}) | ||
} | ||
|
||
Hash.salt = salt | ||
|
||
module.exports = Hash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const path = require('path') | ||
const assert = require('assert') | ||
const file1 = require('./identical-file1.js') | ||
const file2 = require('./identical-file2.js') | ||
|
||
assert.equal(file1(), file2()) | ||
|
||
const cov = (new Function('return this.__coverage__'))() | ||
|
||
assert.deepEqual(Object.keys(cov).sort(), [ | ||
__filename, | ||
path.resolve('identical-file1.js'), | ||
path.resolve('identical-file2.js') | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function identical() { | ||
return 'identical' | ||
} | ||
|
||
module.exports = identical |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function identical() { | ||
return 'identical' | ||
} | ||
|
||
module.exports = identical |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters