MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / whichNodeAsync

Function whichNodeAsync

source code/utils/which.ts:6–33  ·  view source on GitHub ↗
(command: string)

Source from the content-addressed store, hash-verified

4import { execSync_DEPRECATED } from './execSyncWrapper.js'
5
6async 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
35function whichNodeSync(command: string): string | null {
36 if (process.platform === 'win32') {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected