MCPcopy Create free account
hub / github.com/freecodexyz/free-code / hasCommand

Function hasCommand

src/services/voice.ts:77–89  ·  view source on GitHub ↗
(cmd: string)

Source from the content-addressed store, hash-verified

75// ─── Dependency check ────────────────────────────────────────────────
76
77function hasCommand(cmd: string): boolean {
78 // Spawn the target directly instead of `which cmd`. On Termux/Android
79 // `which` is a shell builtin — the external binary is absent or
80 // kernel-blocked (EPERM) when spawned from Node. Only reached on
81 // non-Windows (win32 returns early from all callers), no PATHEXT issue.
82 // result.error is set iff the spawn itself fails (ENOENT/EACCES); exit
83 // code is irrelevant — an unrecognized --version still means cmd exists.
84 const result = spawnSync(cmd, ['--version'], {
85 stdio: 'ignore',
86 timeout: 3000,
87 })
88 return result.error === undefined
89}
90
91// Probe whether arecord can actually open a capture device. hasCommand()
92// only checks PATH; on WSL1/Win10-WSL2/headless Linux the binary exists

Callers 7

detectPackageManagerFunction · 0.70
checkVoiceDependenciesFunction · 0.70
startRecordingFunction · 0.70
resolveSkillNameFunction · 0.50
PromptInputFunction · 0.50
processSlashCommandFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected