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

Function codexSpawnInvocation

src/codex-spawn.ts:24–48  ·  view source on GitHub ↗
(
  args: readonly string[],
  env: NodeJS.ProcessEnv = process.env,
  platform: NodeJS.Platform = process.platform,
  cwd = process.cwd(),
)

Source from the content-addressed store, hash-verified

22}
23
24export function codexSpawnInvocation(
25 args: readonly string[],
26 env: NodeJS.ProcessEnv = process.env,
27 platform: NodeJS.Platform = process.platform,
28 cwd = process.cwd(),
29): CodexSpawnInvocation {
30 const configuredCommand = codexProcessCommand(env);
31 const command =
32 platform === "win32" ? resolveWindowsCommand(configuredCommand, env, cwd) : configuredCommand;
33 if (platform !== "win32" || windowsExecutablePattern.test(command)) {
34 return { command, args: [...args] };
35 }
36
37 const normalizedCommand = normalize(command);
38 const doubleEscapeMetaCharacters = windowsBatchLauncherPattern.test(normalizedCommand);
39 const shellCommand = [
40 escapeWindowsCommand(normalizedCommand),
41 ...args.map((arg) => escapeWindowsArgument(arg, doubleEscapeMetaCharacters)),
42 ].join(" ");
43 return {
44 command: windowsSystemExecutable("cmd.exe", env),
45 args: ["/d", "/s", "/c", `"${shellCommand}"`],
46 windowsVerbatimArguments: true,
47 };
48}
49
50export function terminateCodexProcessTree(
51 child: ChildProcess,

Callers 2

spawnCodexFunction · 0.85

Calls 6

codexProcessCommandFunction · 0.85
resolveWindowsCommandFunction · 0.85
normalizeFunction · 0.85
escapeWindowsCommandFunction · 0.85
escapeWindowsArgumentFunction · 0.85
windowsSystemExecutableFunction · 0.85

Tested by

no test coverage detected