MCPcopy Index your code
hub / github.com/callstack/agent-device / whichCmd

Function whichCmd

src/utils/exec.ts:209–231  ·  view source on GitHub ↗
(cmd: string)

Source from the content-addressed store, hash-verified

207}
208
209export async function whichCmd(cmd: string): Promise<boolean> {
210 const candidate = normalizeExecutableLookup(cmd);
211 if (!candidate) return false;
212
213 if (path.isAbsolute(candidate)) {
214 return isExecutablePath(candidate);
215 }
216
217 const pathValue = process.env.PATH;
218 if (!pathValue) return false;
219 const pathExtensions = resolvePathExtensions();
220 for (const directory of pathValue.split(path.delimiter)) {
221 const trimmedDirectory = directory.trim();
222 if (!trimmedDirectory) continue;
223 for (const entry of resolveExecutableCandidates(candidate, pathExtensions)) {
224 if (await isExecutablePath(path.join(trimmedDirectory, entry))) {
225 return true;
226 }
227 }
228 }
229
230 return false;
231}
232
233export async function resolveExecutableOverridePath(
234 rawPath: string | undefined,

Callers 5

exec.test.tsFile · 0.90
summarizeScreenshotOcrFunction · 0.90
listAndroidDevicesFunction · 0.90

Calls 4

isExecutablePathFunction · 0.85
resolvePathExtensionsFunction · 0.85

Tested by

no test coverage detected