Avoid probing extra executable candidates (#996)

This commit is contained in:
Mohamed Boudra
2026-05-13 15:14:47 +00:00
committed by GitHub
parent ecc6a269bc
commit 512702fe46
+6 -5
View File
@@ -126,11 +126,12 @@ export async function findExecutable(
} }
const candidates = await enumerateCandidates(trimmed); const candidates = await enumerateCandidates(trimmed);
const probeResults = await Promise.all( for (const candidate of candidates) {
candidates.map((candidate) => probeExecutable(candidate, probeTimeoutMs)), if (await probeExecutable(candidate, probeTimeoutMs)) {
); return candidate;
const firstMatch = probeResults.findIndex((result) => result); }
return firstMatch === -1 ? null : candidates[firstMatch]; }
return null;
} }
export async function isCommandAvailable(command: string): Promise<boolean> { export async function isCommandAvailable(command: string): Promise<boolean> {