MCPcopy
hub / github.com/openclaw/clawsweeper / resolveWindowsCommand

Function resolveWindowsCommand

src/codex-spawn.ts:114–134  ·  view source on GitHub ↗
(command: string, env: NodeJS.ProcessEnv, cwd: string)

Source from the content-addressed store, hash-verified

112}
113
114function resolveWindowsCommand(command: string, env: NodeJS.ProcessEnv, cwd: string): string {
115 if (isAbsolute(command) || /[\\/]/.test(command)) {
116 return resolve(cwd, command);
117 }
118 const extensions = (windowsEnvironmentValue(env, "PATHEXT") || ".COM;.EXE;.BAT;.CMD")
119 .split(";")
120 .filter(Boolean)
121 .map((extension) => extension.toLowerCase());
122 const candidates = extensions.includes("")
123 ? [command]
124 : [command, ...extensions.map((extension) => `${command}${extension}`)];
125 for (const directory of (windowsEnvironmentValue(env, "PATH") || "")
126 .split(delimiter)
127 .filter(Boolean)) {
128 for (const candidate of candidates) {
129 const filePath = resolve(cwd, directory, candidate);
130 if (existsSync(filePath)) return filePath;
131 }
132 }
133 throw new Error(`Unable to resolve Windows Codex command: ${command}`);
134}
135
136function windowsSystemExecutable(name: string, env: NodeJS.ProcessEnv): string {
137 const systemRoot =

Callers 1

codexSpawnInvocationFunction · 0.85

Calls 1

windowsEnvironmentValueFunction · 0.85

Tested by

no test coverage detected