MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / findExecutablesOnPath

Function findExecutablesOnPath

packages/kaos/src/environment.ts:265–285  ·  view source on GitHub ↗
(
  name: string,
  pathEnv: string | undefined,
  platform: string,
  isFile: (p: string) => Promise<boolean>,
)

Source from the content-addressed store, hash-verified

263}
264
265async function findExecutablesOnPath(
266 name: string,
267 pathEnv: string | undefined,
268 platform: string,
269 isFile: (p: string) => Promise<boolean>,
270): Promise<readonly string[]> {
271 if (pathEnv === undefined || pathEnv.length === 0) return [];
272 const listSep = platform === 'win32' ? ';' : ':';
273 const dirSep = platform === 'win32' ? '\\' : '/';
274 const paths: string[] = [];
275 for (const rawDir of pathEnv.split(listSep)) {
276 const dir = rawDir.trim();
277 if (dir.length === 0) continue;
278 if (platform === 'win32' && !isAbsoluteWindowsPath(dir)) continue;
279 const candidate = dir.endsWith(dirSep) ? `${dir}${name}` : `${dir}${dirSep}${name}`;
280 if (await isFile(candidate)) {
281 paths.push(candidate);
282 }
283 }
284 return platform === 'win32' ? dedupeWindowsPaths(paths) : paths;
285}
286
287export async function execFileText(
288 file: string,

Callers 1

locateWindowsGitBashFunction · 0.85

Calls 4

isAbsoluteWindowsPathFunction · 0.85
dedupeWindowsPathsFunction · 0.85
isFileFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected