Skip to content

Commit 9c38694

Browse files
committed
fix(caching): fixes a possible cache collision
1 parent 097f867 commit 9c38694

2 files changed

Lines changed: 35 additions & 19 deletions

File tree

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
// this is a template!
22

3-
const fs = require('fs');
4-
const path = require('path');
5-
const root = __dirname;
6-
const writeProcessIoTo = {{writeProcessIoTo}};
3+
const fs = require('fs')
4+
const path = require('path')
5+
const root = __dirname
6+
const writeProcessIoTo = {{writeProcessIoTo}}
77

88
exports.afterProcess = function (args, result) {
9-
// const source = args[0];
10-
const filePath = args[1];
11-
const relPath = path.relative(root, filePath);
9+
// const source = args[0]
10+
const filePath = args[1]
11+
const relPath = path.relative(root, filePath)
1212
if (writeProcessIoTo && filePath.startsWith(`${root}${path.sep}`)) {
13-
const dest = `${path.join(writeProcessIoTo, relPath)}.json`;
14-
const segments = relPath.split(path.sep);
15-
segments.pop();
16-
const madeSegments = [];
13+
const dest = `${path.join(writeProcessIoTo, relPath)}.json`
14+
const segments = relPath.split(path.sep)
15+
segments.pop()
16+
const madeSegments = []
1717
segments.forEach(segment => {
18-
madeSegments.push(segment);
19-
const p = join(writeProcessIoTo, madeSegments.join(sep));
20-
if (!fs.existsSync(p)) fs.mkdirSync(p);
21-
});
18+
madeSegments.push(segment)
19+
const p = path.join(writeProcessIoTo, madeSegments.join(path.sep))
20+
if (!fs.existsSync(p)) fs.mkdirSync(p)
21+
})
2222
fs.writeFileSync(dest, JSON.stringify({
2323
in: args,
2424
out: result,
25-
}), 'utf8');
25+
}), 'utf8')
2626
}
2727
}

src/config/config-set.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { version as myVersion } from '..'
3939
import semver from 'semver'
4040
import { rootLogger } from '../util/logger'
4141
import { Logger } from 'bs-logger'
42+
import { getPackageVersion } from '../util/get-package-version'
4243

4344
const logger = rootLogger.child({ namespace: 'config' })
4445

@@ -235,7 +236,7 @@ export class ConfigSet {
235236
tsConfig,
236237
babelConfig,
237238
diagnostics,
238-
typeCheck: !!options.typeCheck,
239+
isolatedModules: !!options.isolatedModules,
239240
compiler: options.compiler || 'typescript',
240241
stringifyContentPathRegex,
241242
}
@@ -251,6 +252,21 @@ export class ConfigSet {
251252
return this._typescript.input
252253
}
253254

255+
@Memoize()
256+
get versions(): Record<string, string> {
257+
const modules = ['jest', this.tsJest.compiler, 'tslib']
258+
if (this.tsJest.babelConfig) {
259+
modules.push('@babel/core', 'babel-core', 'babel-jest')
260+
}
261+
return modules.reduce(
262+
(map, name) => {
263+
map[name] = getPackageVersion(name) || '-'
264+
return map
265+
},
266+
{ 'ts-jest': myVersion } as Record<string, string>,
267+
)
268+
}
269+
254270
@Memoize()
255271
private get _typescript(): ReadTsConfigResult {
256272
const {
@@ -423,7 +439,7 @@ export class ConfigSet {
423439
version: this.compilerModule.version,
424440
compiler: this.tsJest.compiler,
425441
compilerOptions: this.typescript.options,
426-
typeCheck: this.tsJest.typeCheck,
442+
isolatedModules: this.tsJest.isolatedModules,
427443
ignoreDiagnostics: this.tsJest.diagnostics.ignoreCodes,
428444
}),
429445
)
@@ -555,7 +571,7 @@ export class ConfigSet {
555571
delete globals['ts-jest']
556572

557573
return new JsonableValue({
558-
version: myVersion,
574+
versions: this.versions,
559575
jest,
560576
tsJest: this.tsJest,
561577
babel: this.babel,

0 commit comments

Comments
 (0)