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