MCPcopy Create free account
hub / github.com/Gan-Xing/CodexBridge / findCommandOnPath

Function findCommandOnPath

packages/codex-native-api/src/daemon_manager.ts:1197–1226  ·  view source on GitHub ↗
(
  platform: NodeJS.Platform,
  currentPath: string | undefined,
  candidates: string[],
)

Source from the content-addressed store, hash-verified

1195}
1196
1197function findCommandOnPath(
1198 platform: NodeJS.Platform,
1199 currentPath: string | undefined,
1200 candidates: string[],
1201): string | null {
1202 const pathEntries = String(currentPath ?? '').split(path.delimiter).filter((entry) => entry.trim());
1203 for (const entry of pathEntries) {
1204 for (const candidate of candidates) {
1205 const resolved = path.join(entry, candidate);
1206 if (fs.existsSync(resolved)) {
1207 return resolved;
1208 }
1209 }
1210 if (platform !== 'win32') {
1211 continue;
1212 }
1213 const normalizedCandidates = candidates.flatMap((candidate) => (
1214 candidate.endsWith('.exe') || candidate.endsWith('.cmd') || candidate.endsWith('.bat')
1215 ? [candidate]
1216 : [`${candidate}.exe`, `${candidate}.cmd`, `${candidate}.bat`]
1217 ));
1218 for (const candidate of normalizedCandidates) {
1219 const resolved = path.join(entry, candidate);
1220 if (fs.existsSync(resolved)) {
1221 return resolved;
1222 }
1223 }
1224 }
1225 return null;
1226}
1227
1228async function removeIfExists(filePath: string | null): Promise<void> {
1229 if (!filePath) {

Callers 1

buildDaemonInstallPlanFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected