From ff76a36104d2b9c34079b7f1c1297cc60e75750d Mon Sep 17 00:00:00 2001 From: fisker Date: Wed, 10 Jun 2026 20:05:26 +0800 Subject: [PATCH 1/4] Allow same version --- .github/workflows/ci.yml | 2 +- src/execute-command.ts | 20 +++++++++++++++----- src/run-prettier.ts | 4 ++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5622e4b..6ac2417 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,4 +44,4 @@ jobs: key: v2-${{ hashFiles('repositories.json') }} - uses: actions/setup-node@v6 - run: yarn - - run: yarn execute "RUN https://pkg.pr.new/prettier/prettier@main VS latest" + - run: yarn execute "RUN https://pkg.pr.new/prettier/prettier@main VS https://pkg.pr.new/prettier/prettier@main" diff --git a/src/execute-command.ts b/src/execute-command.ts index 38fab4f..82035ae 100644 --- a/src/execute-command.ts +++ b/src/execute-command.ts @@ -13,14 +13,24 @@ export type ExecuteCommandResult = Awaited>; export async function executeCommand(commandString: string) { const { alternative, original, repositories } = parseCommand(commandString); + const isSame = alternative.raw === original.raw; + const directory = await createTemporaryDirectory(); // Install Prettier - const [alternativePrettier, originalPrettier] = await Promise.all( - [original, alternative].map((version) => - installPrettier(version, { cwd: directory }), - ), - ); + let alternativePrettier; + let originalPrettier; + if (isSame) { + alternativePrettier = originalPrettier = await installPrettier(original, { + cwd: directory, + }); + } else { + [alternativePrettier, originalPrettier] = await Promise.all( + [original, alternative].map((version) => + installPrettier(version, { cwd: directory }), + ), + ); + } await logger.brief( `Running Prettier on ${repositories.length} repositories ...`, diff --git a/src/run-prettier.ts b/src/run-prettier.ts index 0996c00..9b55ec8 100644 --- a/src/run-prettier.ts +++ b/src/run-prettier.ts @@ -95,6 +95,10 @@ export async function runPrettier( reset, }); + if (alternative === original) { + return ""; + } + await runPrettierWithVersion({ cwd: directory, prettier: alternative, From e3236382d6d3cec956252f4f92f7720f1e160455 Mon Sep 17 00:00:00 2001 From: fisker Date: Wed, 10 Jun 2026 20:08:32 +0800 Subject: [PATCH 2/4] Minor tweak --- src/execute-command.ts | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/execute-command.ts b/src/execute-command.ts index 82035ae..9517e94 100644 --- a/src/execute-command.ts +++ b/src/execute-command.ts @@ -18,19 +18,11 @@ export async function executeCommand(commandString: string) { const directory = await createTemporaryDirectory(); // Install Prettier - let alternativePrettier; - let originalPrettier; - if (isSame) { - alternativePrettier = originalPrettier = await installPrettier(original, { - cwd: directory, - }); - } else { - [alternativePrettier, originalPrettier] = await Promise.all( - [original, alternative].map((version) => - installPrettier(version, { cwd: directory }), - ), - ); - } + const promises = [installPrettier(original, { cwd: directory })]; + promises.push( + isSame ? promises[0] : installPrettier(alternative, { cwd: directory }), + ); + const [alternativePrettier, originalPrettier] = await Promise.all(promises); await logger.brief( `Running Prettier on ${repositories.length} repositories ...`, From ba1ffc45a1a65e1d1911a518635647ef41848375 Mon Sep 17 00:00:00 2001 From: fisker Date: Wed, 10 Jun 2026 20:09:49 +0800 Subject: [PATCH 3/4] Fix --- src/execute-command.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/execute-command.ts b/src/execute-command.ts index 9517e94..afec375 100644 --- a/src/execute-command.ts +++ b/src/execute-command.ts @@ -18,9 +18,9 @@ export async function executeCommand(commandString: string) { const directory = await createTemporaryDirectory(); // Install Prettier - const promises = [installPrettier(original, { cwd: directory })]; + const promises = [installPrettier(alternative, { cwd: directory })]; promises.push( - isSame ? promises[0] : installPrettier(alternative, { cwd: directory }), + isSame ? promises[0] : installPrettier(original, { cwd: directory }), ); const [alternativePrettier, originalPrettier] = await Promise.all(promises); From 63ce6b185315c89a4347182fc9d8a5e60c8418fe Mon Sep 17 00:00:00 2001 From: fisker Date: Wed, 10 Jun 2026 20:10:57 +0800 Subject: [PATCH 4/4] timing --- src/run-prettier.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/run-prettier.ts b/src/run-prettier.ts index 9b55ec8..01ffa2f 100644 --- a/src/run-prettier.ts +++ b/src/run-prettier.ts @@ -96,6 +96,7 @@ export async function runPrettier( }); if (alternative === original) { + timing.end(); return ""; }