Skip to content

Commit ea13794

Browse files
DEV CI
1 parent 7bbae34 commit ea13794

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

packages/jest-transform/src/ScriptTransformer.ts

+28-17
Original file line numberDiff line numberDiff line change
@@ -542,26 +542,35 @@ 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+
// failure
552+
if (this.shouldTransform(filename)) {
553+
// failed
554+
shouldCallTransform = true;
555+
const process = transformer.processAsync ?? transformer.process;
556+
557+
// This is probably dead code since `_getTransformerAsync` already asserts this
558+
invariant(
559+
typeof process === 'function',
560+
'A transformer must always export either a `process` or `processAsync`',
561+
);
554562

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

564-
createDirectory(path.dirname(filename));
573+
createDirectory(path.dirname(cacheFilePath));
565574
return this._buildTransformResult(
566575
filename,
567576
cacheFilePath,
@@ -811,10 +820,12 @@ class ScriptTransformer {
811820
}
812821

813822
shouldTransform(filename: string): boolean {
823+
// failed
814824
const ignoreRegexp = this._cache.ignorePatternsRegExp;
815825
const isIgnored = ignoreRegexp ? ignoreRegexp.test(filename) : false;
816826

817827
return this._config.transform.length !== 0 && !isIgnored;
828+
// failed
818829
}
819830
}
820831

0 commit comments

Comments
 (0)