diff --git a/src/install/deps.ts b/src/install/deps.ts index 68d73b6..fd66561 100644 --- a/src/install/deps.ts +++ b/src/install/deps.ts @@ -352,16 +352,6 @@ export async function resolveWindowsCommandPath( return undefined; } -function quoteWindowsShellArgument(argument: string): string { - if (argument.length === 0) { - return '""'; - } - - return /[\s"&()<>^|]/u.test(argument) - ? `"${argument.replaceAll('"', '""')}"` - : argument; -} - function createCommandNotFoundError(command: string): NodeJS.ErrnoException { const error = new Error(`spawn ${command} ENOENT`) as NodeJS.ErrnoException; @@ -408,12 +398,8 @@ export async function prepareInstallCommand( }; } - const commandLine = [resolvedCommandPath, ...args] - .map(quoteWindowsShellArgument) - .join(" "); - return { - args: ["/d", "/s", "/c", commandLine], + args: ["/d", "/s", "/c", resolvedCommandPath, ...args], command: getEnvironmentValue(normalizedEnv, "ComSpec", platform) ?? "cmd.exe", windowsHide: true, diff --git a/test/install/deps.test.ts b/test/install/deps.test.ts index 7e5d41c..a48da53 100644 --- a/test/install/deps.test.ts +++ b/test/install/deps.test.ts @@ -64,7 +64,10 @@ test("prepareInstallCommand routes Windows .cmd shims through ComSpec", async () "/d", "/s", "/c", - '"C:\\Program Files\\OpenCode\\opencode.CMD" debug config --pure', + "C:\\Program Files\\OpenCode\\opencode.CMD", + "debug", + "config", + "--pure", ]); }); diff --git a/test/install/verify-effective.test.ts b/test/install/verify-effective.test.ts index 5aed726..21d1ca9 100644 --- a/test/install/verify-effective.test.ts +++ b/test/install/verify-effective.test.ts @@ -1192,3 +1192,42 @@ test("the fake opencode harness also supports plain debug config invocations for await harness.cleanup(); } }); + +test("the fake opencode harness supports debug config --pure invocations through the real command runner", async () => { + const harness = await createInstallIntegrationHarness(); + + try { + await harness.installFakeOpenCodeOnPath({ + debugConfigPureOutput: '{\n "mode": "pure"\n}\n', + output: "opencode-ai 1.4.0", + }); + + const dependencies = harness.createDependencies(); + const result = await dependencies.commands.run( + "opencode", + ["debug", "config", "--pure"], + { + cwd: dependencies.runtime.cwd, + env: dependencies.runtime.env, + }, + ); + + assert.equal(result.exitCode, 0); + assert.match(result.stdout, /"mode": "pure"/); + + const invocations = await harness.readFakeOpenCodeInvocations(); + + assert.equal( + invocations.some( + (args) => + args.length === 3 && + args[0] === "debug" && + args[1] === "config" && + args[2] === "--pure", + ), + true, + ); + } finally { + await harness.cleanup(); + } +});