Skip to content

Commit

Permalink
Patch jest-runner-prettier to work with Prettier 3 (#2363)
Browse files Browse the repository at this point in the history
# Summary

I completely forgot about keplersj/jest-runner-prettier#586 and this has been broken for a while.

# Test Plan

This is why I love `pnpm`

```shell
pnpm patch jest-runner-prettier
# add the awaits everywhere
pnpm patch-commit '/tmp/67d6a1a8e116289cd91a5e6eeb4f413d'
```

Break formatting in a file. `pnpm test:prettier`. Finally it registers.
  • Loading branch information
steveluscher committed Mar 22, 2024
1 parent 0a19b75 commit 5908de2
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
"jsdom": "^22",
"mock-socket": "^9.3.1",
"shelljs": ">=0.8.5"
},
"patchedDependencies": {
"jest-runner-prettier@1.0.0": "patches/jest-runner-prettier@1.0.0.patch"
}
},
"prettier": "@solana/prettier-config-solana"
Expand Down
44 changes: 44 additions & 0 deletions patches/jest-runner-prettier@1.0.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
diff --git a/dist/run.js b/dist/run.js
index fdee17d2377dd013d55de1d54bee9d241894e800..7139e496da63da74b3e7966f4a3f5a613a7f3b3b 100644
--- a/dist/run.js
+++ b/dist/run.js
@@ -11,7 +11,7 @@ export default async ({ testPath }) => {
...config,
filepath: testPath,
};
- const isPretty = prettier.check(contents, prettierConfig);
+ const isPretty = await prettier.check(contents, prettierConfig);
if (isPretty) {
return pass({
start,
@@ -19,7 +19,7 @@ export default async ({ testPath }) => {
test: { path: testPath },
});
}
- const formatted = prettier.format(contents, prettierConfig);
+ const formatted = await prettier.format(contents, prettierConfig);
return fail({
start,
end: Date.now(),
diff --git a/src/run.ts b/src/run.ts
index 1775851defdca87b753f1f9bae1cb663332eb640..b6c72e13f82d9e9ed3aef5095f8b8d82e2b4391b 100644
--- a/src/run.ts
+++ b/src/run.ts
@@ -19,7 +19,7 @@ export default async ({ testPath }: Parameters): Promise<TestResult> => {
filepath: testPath,
};

- const isPretty = prettier.check(contents, prettierConfig);
+ const isPretty = await prettier.check(contents, prettierConfig);
if (isPretty) {
return pass({
start,
@@ -28,7 +28,7 @@ export default async ({ testPath }: Parameters): Promise<TestResult> => {
});
}

- const formatted = prettier.format(contents, prettierConfig);
+ const formatted = await prettier.format(contents, prettierConfig);

return fail({
start,
10 changes: 8 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5908de2

Please sign in to comment.