Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[jest-heft-plugin] Remove the Jest postinstall step. #3790

Merged
merged 2 commits into from
Nov 29, 2022

Conversation

iclanton
Copy link
Member

This PR removes the Jest postinstall step. PNPM's patch feature is a better solution to this problem.

The patch should look like this @jest__transform@27.4.5.patch:

diff --git a/build/ScriptTransformer.js b/build/ScriptTransformer.js
index fb7b610e9559e11b2e58dd7a39f565c98ce6ed1d..cdb923705cd18aca87e134e93b7c14c7a48cd4a1 100644
--- a/build/ScriptTransformer.js
+++ b/build/ScriptTransformer.js
@@ -1002,24 +1002,7 @@ function readCodeCacheFile(cachePath) {
  */
 
 const writeCacheFile = (cachePath, fileData) => {
-  try {
-    (0, _writeFileAtomic().sync)(cachePath, fileData, {
-      encoding: 'utf8',
-      fsync: false
-    });
-  } catch (e) {
-    if (cacheWriteErrorSafeToIgnore(e, cachePath)) {
-      return;
-    }
-
-    e.message =
-      'jest: failed to cache transform results in: ' +
-      cachePath +
-      '\nFailure message: ' +
-      e.message;
-    removeFile(cachePath);
-    throw e;
-  }
+  return;
 };
 /**
  * On Windows, renames are not atomic, leading to EPERM exceptions when two
@@ -1034,31 +1017,7 @@ const cacheWriteErrorSafeToIgnore = (e, cachePath) =>
   fs().existsSync(cachePath);
 
 const readCacheFile = cachePath => {
-  if (!fs().existsSync(cachePath)) {
-    return null;
-  }
-
-  let fileData;
-
-  try {
-    fileData = fs().readFileSync(cachePath, 'utf8');
-  } catch (e) {
-    e.message =
-      'jest: failed to read cache file: ' +
-      cachePath +
-      '\nFailure message: ' +
-      e.message;
-    removeFile(cachePath);
-    throw e;
-  }
-
-  if (fileData == null) {
-    // We must have somehow created the file but failed to write to it,
-    // let's delete it and retry.
-    removeFile(cachePath);
-  }
-
-  return fileData;
+  return;
 };
 
 const getScriptCacheKey = (filename, instrument) => {

@iclanton iclanton merged commit 0a46e7e into microsoft:main Nov 29, 2022
@iclanton iclanton deleted the remove-postinstall branch November 29, 2022 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants