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

Function isBinaryInstalled

source code/utils/binaryCheck.ts:16–48  ·  view source on GitHub ↗
(command: string)

Source from the content-addressed store, hash-verified

14 * @returns Promise<boolean> - true if the command exists, false otherwise
15 */
16export async function isBinaryInstalled(command: string): Promise<boolean> {
17 // Edge case: empty or whitespace-only command
18 if (!command || !command.trim()) {
19 logForDebugging('[binaryCheck] Empty command provided, returning false')
20 return false
21 }
22
23 // Trim the command to handle whitespace
24 const trimmedCommand = command.trim()
25
26 // Check cache first
27 const cached = binaryCache.get(trimmedCommand)
28 if (cached !== undefined) {
29 logForDebugging(
30 `[binaryCheck] Cache hit for '${trimmedCommand}': ${cached}`,
31 )
32 return cached
33 }
34
35 let exists = false
36 if (await which(trimmedCommand).catch(() => null)) {
37 exists = true
38 }
39
40 // Cache the result
41 binaryCache.set(trimmedCommand, exists)
42
43 logForDebugging(
44 `[binaryCheck] Binary '${trimmedCommand}' ${exists ? 'found' : 'not found'}`,
45 )
46
47 return exists
48}
49
50/**
51 * Clear the binary check cache (useful for testing)

Callers 1

getMatchingLspPluginsFunction · 0.85

Calls 3

logForDebuggingFunction · 0.85
setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected