fix(files-widget): use 'where' instead of 'which' on Windows for dep detection#44
Open
hhelibeb wants to merge 1 commit into
Open
fix(files-widget): use 'where' instead of 'which' on Windows for dep detection#44hhelibeb wants to merge 1 commit into
hhelibeb wants to merge 1 commit into
Conversation
…detection
'which' is a Unix command not available in cmd.exe, which Node.js
uses as the default shell on Windows. When running pi from PowerShell
or cmd.exe, 'execSync(`which ${cmd}`)' always fails, causing the
startup dependency check to report bat, delta, and glow as missing
even when they are installed and on PATH.
Use 'where' on Windows (the platform-native equivalent) and keep
'which' on other platforms.
Fixes dependency detection for Windows users of /readfiles.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
hasCommand()useswhichviaexecSync()to detect whetherbat,delta, andgloware installed. On Windows, Node.js'sexecSync()defaults tocmd.exeas the shell, wherewhichis not a valid command. This causes the check to always fail, and the startup dependency warning fires even when all three tools are installed and on PATH.Fixes dependency detection for
/readfileson Windows.Behavior
process.platform === "win32"), useswhere— the Windows command available from the defaultcmd.exeshell used by Node.js'sexecSync().which— no change for existing users.Implementation
Small change in
hasCommand()insideutils.ts: platform-conditional command selection before theexecSynccall.Testing
where bat/where delta/where glowreturn exit code 0 fromcmd.exeon Windows 11.bat,delta, andgloware correctly found whenhasCommanduseswherefrom a Node.jsexecSync()context on Windows, regardless of whether pi is launched from PowerShell or Git Bash (on Windows,process.platformis always"win32", so thewherepath is taken).whichfallback (macOS/Linux path) is kept unchanged; no behavioral regression expected.