Fixes executable path resolution on Windows
Updates the executable path resolution logic to correctly identify executables on Windows systems by using the 'where' command instead of 'which', which is not available on Windows. This change ensures that the application can locate and execute dependencies properly, regardless of the operating system. It also uses `path.isAbsolute` to accurately determine if a user-provided path is absolute, improving the reliability of path resolution.
This commit is contained in:
2 files changed
+23
-11
No files matched your search
@@ -27,13 +27,17 @@ export class PathResolver {
|
||||
|
||||
// Try to find the executable using which command
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
// Use platform-specific command: 'where' on Windows, 'which' on Unix
|
||||
const whichCommand = process.platform === 'win32' ? 'where' : 'which';
|
||||
|
||||
try {
|
||||
const augmentedEnv = {
|
||||
...process.env,
|
||||
PATH: `/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:${process.env.PATH || ''}`
|
||||
};
|
||||
|
||||
const result = spawnSync('which', [defaultName], {
|
||||
|
||||
const result = spawnSync(whichCommand, [defaultName], {
|
||||
encoding: 'utf8',
|
||||
env: augmentedEnv
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user