Skip to content

Commit ef69253

Browse files
DEV CI
1 parent d71dbbe commit ef69253

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

packages/jest-transform/src/ScriptTransformer.ts

+27-17
Original file line numberDiff line numberDiff line change
@@ -542,23 +542,31 @@ class ScriptTransformer {
542542

543543
let shouldCallTransform = false;
544544

545-
if (transformer && this.shouldTransform(filename)) {
546-
shouldCallTransform = true;
547-
const process = transformer.processAsync ?? transformer.process;
548-
549-
// This is probably dead code since `_getTransformerAsync` already asserts this
550-
invariant(
551-
typeof process === 'function',
552-
'A transformer must always export either a `process` or `processAsync`',
553-
);
545+
// success
546+
// success
547+
if (transformer) {
548+
if (cacheFilePath) {
549+
createDirectory(path.dirname(cacheFilePath));
550+
}
551+
if (this.shouldTransform(filename, cacheFilePath)) {
552+
// failed
553+
shouldCallTransform = true;
554+
const process = transformer.processAsync ?? transformer.process;
555+
556+
// This is probably dead code since `_getTransformerAsync` already asserts this
557+
invariant(
558+
typeof process === 'function',
559+
'A transformer must always export either a `process` or `processAsync`',
560+
);
554561

555-
processed = await process(content, filename, {
556-
...options,
557-
cacheFS: this._cacheFS,
558-
config: this._config,
559-
configString: this._cache.configString,
560-
transformerConfig,
561-
});
562+
processed = await process(content, filename, {
563+
...options,
564+
cacheFS: this._cacheFS,
565+
config: this._config,
566+
configString: this._cache.configString,
567+
transformerConfig,
568+
});
569+
}
562570
}
563571

564572
createDirectory(path.dirname(filename));
@@ -810,11 +818,13 @@ class ScriptTransformer {
810818
}
811819
}
812820

813-
shouldTransform(filename: string): boolean {
821+
shouldTransform(filename: string, cacheFilePath?: string): boolean {
822+
// failed
814823
const ignoreRegexp = this._cache.ignorePatternsRegExp;
815824
const isIgnored = ignoreRegexp ? ignoreRegexp.test(filename) : false;
816825

817826
return this._config.transform.length !== 0 && !isIgnored;
827+
// failed
818828
}
819829
}
820830

0 commit comments

Comments
 (0)