MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / hasCommand

Function hasCommand

src/upgrade/index.ts:903–921  ·  view source on GitHub ↗
(cmd: string)

Source from the content-addressed store, hash-verified

901 * ourselves behaves identically on every platform.
902 */
903export function hasCommand(cmd: string): boolean {
904 const isWin = process.platform === 'win32';
905 const dirs = (process.env.PATH || process.env.Path || '').split(path.delimiter).filter(Boolean);
906 const exts = isWin ? (process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM').split(';') : [''];
907 for (const dir of dirs) {
908 for (const ext of exts) {
909 const candidate = path.join(dir, cmd + ext);
910 try {
911 if (!fs.statSync(candidate).isFile()) continue;
912 if (isWin) return true;
913 fs.accessSync(candidate, fs.constants.X_OK);
914 return true;
915 } catch {
916 /* not here / not executable — keep scanning */
917 }
918 }
919 }
920 return false;
921}
922
923export function defaultRun(cmd: string, args: string[], env?: NodeJS.ProcessEnv, cwd?: string): number {
924 const r = spawnSync(cmd, args, { stdio: 'inherit', env: env ?? process.env, windowsHide: true, cwd });

Callers

nothing calls this directly

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected