fix(windows): resolve EINVAL error when opening worktree in VS Code (#434)
execFile doesn't search PATH on Windows, causing batch files like code.cmd to fail with EINVAL. Use spawn with shell: true for Windows batch file commands (.cmd, .bat) to allow PATH resolution. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Andy <119136210+AndyMik90@users.noreply.github.com>
This commit is contained in:
@@ -977,6 +977,20 @@ async function openInIDE(dirPath: string, ide: SupportedIDE, customPath?: string
|
||||
}
|
||||
}
|
||||
|
||||
// Special handling for Windows batch files (.cmd, .bat)
|
||||
// execFile doesn't search PATH, so we need shell: true for batch files
|
||||
if (platform === 'win32' && (command.endsWith('.cmd') || command.endsWith('.bat'))) {
|
||||
return new Promise((resolve) => {
|
||||
const child = spawn(command, [dirPath], {
|
||||
shell: true,
|
||||
detached: true,
|
||||
stdio: 'ignore'
|
||||
});
|
||||
child.unref();
|
||||
resolve({ success: true });
|
||||
});
|
||||
}
|
||||
|
||||
// Use command line tool with execFileAsync
|
||||
await execFileAsync(command, [dirPath]);
|
||||
return { success: true };
|
||||
|
||||
Reference in New Issue
Block a user