From 8d7a2082d2ccb7fdba797bf7d61c3ca3393a3834 Mon Sep 17 00:00:00 2001 From: Mitchell Hentges Date: Fri, 14 Oct 2022 18:34:48 +0100 Subject: [PATCH] DEV CI --- .../jest-transform/src/ScriptTransformer.ts | 44 ++++++++++++------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/packages/jest-transform/src/ScriptTransformer.ts b/packages/jest-transform/src/ScriptTransformer.ts index adaabfaef07c..e464d04ca4b1 100644 --- a/packages/jest-transform/src/ScriptTransformer.ts +++ b/packages/jest-transform/src/ScriptTransformer.ts @@ -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)); @@ -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 } }