( args: readonly string[], env: NodeJS.ProcessEnv = process.env, platform: NodeJS.Platform = process.platform, cwd = process.cwd(), )
| 22 | } |
| 23 | |
| 24 | export 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 | |
| 50 | export function terminateCodexProcessTree( |
| 51 | child: ChildProcess, |
no test coverage detected