summaryrefslogtreecommitdiff
path: root/packages/core/src/utils/editor.ts
diff options
context:
space:
mode:
authormatt korwel <[email protected]>2025-06-09 12:19:42 -0700
committerGitHub <[email protected]>2025-06-09 12:19:42 -0700
commit3b943c1582026bdf65feb13a73259ce0e034ab2f (patch)
tree3368aa85053b8599fe1fb1349383736890ea73e0 /packages/core/src/utils/editor.ts
parent2182a1cd2cb83071b9defad2314a689d773363e7 (diff)
Windows: Refactor Shell Scripts to Node.js for Cross-Platform Compatibility (#784)
Diffstat (limited to 'packages/core/src/utils/editor.ts')
-rw-r--r--packages/core/src/utils/editor.ts14
1 files changed, 11 insertions, 3 deletions
diff --git a/packages/core/src/utils/editor.ts b/packages/core/src/utils/editor.ts
index 447aa0d2..6be5cffb 100644
--- a/packages/core/src/utils/editor.ts
+++ b/packages/core/src/utils/editor.ts
@@ -15,7 +15,10 @@ interface DiffCommand {
function commandExists(cmd: string): boolean {
try {
- execSync(`which ${cmd}`, { stdio: 'ignore' });
+ execSync(
+ process.platform === 'win32' ? `where.exe ${cmd}` : `command -v ${cmd}`,
+ { stdio: 'ignore' },
+ );
return true;
} catch {
return false;
@@ -24,7 +27,9 @@ function commandExists(cmd: string): boolean {
export function checkHasEditor(editor: EditorType): boolean {
if (editor === 'vscode') {
- return commandExists('code');
+ return process.platform === 'win32'
+ ? commandExists('code.cmd')
+ : commandExists('code');
} else if (editor === 'vim') {
return commandExists('vim');
}
@@ -116,7 +121,10 @@ export async function openDiff(
});
} else {
// Use execSync for terminal-based editors like vim
- const command = `${diffCommand.command} ${diffCommand.args.map((arg) => `"${arg}"`).join(' ')}`;
+ const command =
+ process.platform === 'win32'
+ ? `${diffCommand.command} ${diffCommand.args.join(' ')}`
+ : `${diffCommand.command} ${diffCommand.args.map((arg) => `"${arg}"`).join(' ')}`;
execSync(command, {
stdio: 'inherit',
encoding: 'utf8',