(command: string)
| 2 | import { execSync_DEPRECATED } from './execSyncWrapper.js' |
| 3 | |
| 4 | async function whichNodeAsync(command: string): Promise<string | null> { |
| 5 | if (process.platform === 'win32') { |
| 6 | // On Windows, use where.exe and return the first result |
| 7 | const result = await execa(`where.exe ${command}`, { |
| 8 | shell: true, |
| 9 | stderr: 'ignore', |
| 10 | reject: false, |
| 11 | }) |
| 12 | if (result.exitCode !== 0 || !result.stdout) { |
| 13 | return null |
| 14 | } |
| 15 | // where.exe returns multiple paths separated by newlines, return the first |
| 16 | return result.stdout.trim().split(/\r?\n/)[0] || null |
| 17 | } |
| 18 | |
| 19 | // On POSIX systems (macOS, Linux, WSL), use which |
| 20 | // Cross-platform safe: Windows is handled above |
| 21 | // eslint-disable-next-line custom-rules/no-cross-platform-process-issues |
| 22 | const result = await execa(`which ${command}`, { |
| 23 | shell: true, |
| 24 | stderr: 'ignore', |
| 25 | reject: false, |
| 26 | }) |
| 27 | if (result.exitCode !== 0 || !result.stdout) { |
| 28 | return null |
| 29 | } |
| 30 | return result.stdout.trim() |
| 31 | } |
| 32 | |
| 33 | function whichNodeSync(command: string): string | null { |
| 34 | if (process.platform === 'win32') { |
nothing calls this directly
no outgoing calls
no test coverage detected