Skip to content

Commit

Permalink
DEV CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchhentgesspotify committed Nov 8, 2022
1 parent 7bbae34 commit 8d7a208
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions packages/jest-transform/src/ScriptTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,23 +542,31 @@ class ScriptTransformer {

let shouldCallTransform = false;

if (transformer && this.shouldTransform(filename)) {
shouldCallTransform = true;
const process = transformer.processAsync ?? transformer.process;

// This is probably dead code since `_getTransformerAsync` already asserts this
invariant(
typeof process === 'function',
'A transformer must always export either a `process` or `processAsync`',
);
// success
// success
if (transformer) {
if (cacheFilePath) {
createDirectory(path.dirname(cacheFilePath));
}
if (this.shouldTransform(filename, cacheFilePath)) {
// failed
shouldCallTransform = true;
const process = transformer.processAsync ?? transformer.process;

// This is probably dead code since `_getTransformerAsync` already asserts this
invariant(
typeof process === 'function',
'A transformer must always export either a `process` or `processAsync`',
);

processed = await process(content, filename, {
...options,
cacheFS: this._cacheFS,
config: this._config,
configString: this._cache.configString,
transformerConfig,
});
processed = await process(content, filename, {
...options,
cacheFS: this._cacheFS,
config: this._config,
configString: this._cache.configString,
transformerConfig,
});
}
}

createDirectory(path.dirname(filename));
Expand Down Expand Up @@ -810,11 +818,13 @@ class ScriptTransformer {
}
}

shouldTransform(filename: string): boolean {
shouldTransform(filename: string, cacheFilePath?: string): boolean {
// failed
const ignoreRegexp = this._cache.ignorePatternsRegExp;
const isIgnored = ignoreRegexp ? ignoreRegexp.test(filename) : false;

return this._config.transform.length !== 0 && !isIgnored;
// failed
}
}

Expand Down

0 comments on commit 8d7a208

Please sign in to comment.