From 4bd33f3742e3c21a6ea206648a9c71e818500893 Mon Sep 17 00:00:00 2001 From: Philippe Granger Date: Sat, 24 Jan 2026 20:05:33 +0100 Subject: [PATCH] refactor(editor): extract command construction to shared function Extract the platform-specific command construction into getCommandExistsCmd() to avoid duplication between commandExists and commandExistsAsync. --- packages/core/src/utils/editor.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/core/src/utils/editor.ts b/packages/core/src/utils/editor.ts index 2d16ddd374..cbc1209b67 100644 --- a/packages/core/src/utils/editor.ts +++ b/packages/core/src/utils/editor.ts @@ -76,12 +76,15 @@ interface DiffCommand { const execAsync = promisify(exec); +function getCommandExistsCmd(cmd: string): string { + return process.platform === 'win32' + ? `where.exe ${cmd}` + : `command -v ${cmd}`; +} + function commandExists(cmd: string): boolean { try { - execSync( - process.platform === 'win32' ? `where.exe ${cmd}` : `command -v ${cmd}`, - { stdio: 'ignore' }, - ); + execSync(getCommandExistsCmd(cmd), { stdio: 'ignore' }); return true; } catch { return false; @@ -90,9 +93,7 @@ function commandExists(cmd: string): boolean { async function commandExistsAsync(cmd: string): Promise { try { - await execAsync( - process.platform === 'win32' ? `where.exe ${cmd}` : `command -v ${cmd}`, - ); + await execAsync(getCommandExistsCmd(cmd)); return true; } catch { return false;