Skip to content

Commit

Permalink
make filename cache key relative to rootDir
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Sep 5, 2017
1 parent e9afe00 commit 69456ca
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/babel-jest/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

import type {Path, ProjectConfig} from 'types/Config';
import type {TransformOptions} from 'types/Transform';
import type {CacheKeyOptions, TransformOptions} from 'types/Transform';

import crypto from 'crypto';
import fs from 'fs';
Expand Down Expand Up @@ -82,15 +82,15 @@ const createTransformer = (options: any) => {
fileData: string,
filename: Path,
configString: string,
{instrument}: TransformOptions,
{instrument, rootDir}: CacheKeyOptions,
): string {
return crypto
.createHash('md5')
.update(THIS_FILE)
.update('\0', 'utf8')
.update(fileData)
.update('\0', 'utf8')
.update(filename)
.update(path.relative(rootDir, filename))
.update('\0', 'utf8')
.update(configString)
.update('\0', 'utf8')
Expand Down
1 change: 1 addition & 0 deletions packages/jest-runtime/src/script_transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class ScriptTransformer {
transformer.getCacheKey(fileData, filename, configString, {
instrument,
mapCoverage,
rootDir: this._config.rootDir,
}),
)
.update(CACHE_VERSION)
Expand Down
1 change: 1 addition & 0 deletions types/Transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export type TransformOptions = {|
export type CacheKeyOptions = {|
instrument: boolean,
mapCoverage: boolean,
rootDir: string,
|};

export type Transformer = {|
Expand Down

0 comments on commit 69456ca

Please sign in to comment.