fix(shared): Windows .cmd shims no longer print DEP0190 on every spawn (#19385)

Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Theo BrowneandClaude Opus 5.5 authored and GitHub committed 2026-10-14 04:17:42 -07:00
1 parent f5b5f9dd7b
commit c08093c2b1
8 files changed
+89 -75

No files matched your search

@@ -693,8 +693,11 @@ describe("CodexAdapterV2 process spawning", () => {
if (!ChildProcess.isStandardCommand(command)) {
return;
}
assert.equal(command.command, '^"C:\\npm\\codex.cmd^"');
assert.deepEqual(command.args, ['^"app-server^"', '^"argument^ with^ spaces^"']);
assert.equal(
command.command,
'^"C:\\npm\\codex.cmd^" ^"app-server^" ^"argument^ with^ spaces^"',
);
assert.deepEqual(command.args, []);
assert.equal(command.options.shell, true);
assert.equal(command.options.cwd, "C:\\workspace");
assert.deepEqual(command.options.env, { CUSTOM: "1" });
@@ -153,11 +153,15 @@ it.effect("launches an installed editor with platform-safe arguments", () =>
);
assert.ok(spawned);
assert.equal(spawned.command, '^"C:\\Program^ Files\\Microsoft^ VS^ Code\\bin\\code.CMD^"');
assert.deepEqual(spawned.args, [
'^"--goto^"',
'^"C:\\workspace^ with^ spaces\\src\\index.ts:12:4^"',
]);
assert.equal(
spawned.command,
[
'^"C:\\Program^ Files\\Microsoft^ VS^ Code\\bin\\code.CMD^"',
'^"--goto^"',
'^"C:\\workspace^ with^ spaces\\src\\index.ts:12:4^"',
].join(" "),
);
assert.deepEqual(spawned.args, []);
assert.equal(spawned.options.shell, true);
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
);
@@ -241,12 +245,16 @@ it.effect("launches Cursor in classic IDE mode through the Windows command shim"
);
assert.ok(spawned);
assert.equal(spawned.command, '^"C:\\Program^ Files\\Cursor\\bin\\cursor.CMD^"');
assert.deepEqual(spawned.args, [
'^"--classic^"',
'^"--goto^"',
'^"C:\\workspace^ with^ spaces\\src\\index.ts:12:4^"',
]);
assert.equal(
spawned.command,
[
'^"C:\\Program^ Files\\Cursor\\bin\\cursor.CMD^"',
'^"--classic^"',
'^"--goto^"',
'^"C:\\workspace^ with^ spaces\\src\\index.ts:12:4^"',
].join(" "),
);
assert.deepEqual(spawned.args, []);
assert.equal(spawned.options.shell, true);
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
);
@@ -1033,12 +1041,13 @@ for (const { platform, installPath, editor, args } of [
),
);
assert.ok(spawned);
const shim = executable.endsWith(".cmd");
assert.equal(
spawned.command,
executable.endsWith(".cmd") ? `^"${executable.replaceAll(" ", "^ ")}^"` : executable,
shim ? [`^"${executable.replaceAll(" ", "^ ")}^"`, ...args].join(" ") : executable,
);
assert.deepEqual(spawned.args, args);
assert.equal(spawned.options.shell, executable.endsWith(".cmd"));
assert.deepEqual(spawned.args, shim ? [] : args);
assert.equal(spawned.options.shell, shim);
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
);
}
@@ -1476,10 +1485,12 @@ it.effect("starts a Windows command shim for unicode paths with cmd metacharacte
assert.isTrue(Exit.isSuccess(exit));
assert.ok(spawned);
assert.equal(spawned.options.shell, true);
assert.deepEqual(spawned.args, [
'^"--goto^"',
'^"C:\\Users\\jö\\R^&D^ ^(100^%^)\\naïve^ ^^file^!.ts:3:7^"',
]);
assert.deepEqual(spawned.args, []);
assert.isTrue(
spawned.command.endsWith(
' ^"--goto^" ^"C:\\Users\\jö\\R^&D^ ^(100^%^)\\naïve^ ^^file^!.ts:3:7^"',
),
);
}),
);
+11 -8
View File
@@ -127,14 +127,17 @@ describe("runProcess", () => {
it.effect("resolves and escapes Windows command shims before spawning", () => {
const spawner = makeSpawner((command) =>
Effect.sync(() => {
expect(command.command).toBe('^"C:\\Users\\tester\\AppData\\Roaming\\npm\\az.cmd^"');
expect(command.args).toEqual([
'^"repos^"',
'^"pr^"',
'^"list^"',
'^"--source-branch^"',
'^"feature^ ^&^ release^"',
]);
expect(command.command).toBe(
[
'^"C:\\Users\\tester\\AppData\\Roaming\\npm\\az.cmd^"',
'^"repos^"',
'^"pr^"',
'^"list^"',
'^"--source-branch^"',
'^"feature^ ^&^ release^"',
].join(" "),
);
expect(command.args).toEqual([]);
expect(command.options.shell).toBe(true);
return makeHandle({ stdout: "[]" });
}),
@@ -943,21 +943,16 @@ describe("providerMaintenanceRunner", () => {
const result = yield* runner.updateProvider(CODEX_DRIVER);
// On win32, resolveSpawnCommand resolves `npm` to the `.cmd` shim and
// routes the spawn through cmd.exe (shell: true), escaping every arg.
// routes the spawn through cmd.exe (shell: true) as one escaped line.
assert.strictEqual(captured.length, 1);
const call = captured[0];
assert.ok(call, "expected the spawner to be invoked once");
// The resolved command is the escaped `.cmd` path. Asserting the precise
// escaped string is brittle, so verify it carries the resolved shim and
// that shell mode was used.
assert.match(call.command, /npm\.cmd/i);
assert.strictEqual(
call.command,
'^"C:\\fake\\npm\\npm.cmd^" ^"install^" ^"-g^" ^"@openai/codex@latest^"',
);
assert.deepEqual(call.args, []);
assert.strictEqual(call.shell, true);
// Args are escaped for cmd.exe shell mode (each quoted) but still carry
// the original install command (`install -g @openai/codex@latest`) in order.
assert.strictEqual(call.args.length, 3);
assert.match(call.args[0] ?? "", /install/);
assert.match(call.args[1] ?? "", /-g/);
assert.match(call.args[2] ?? "", /@openai\/codex@latest/);
assert.strictEqual(result.providers[0]?.updateState?.status, "succeeded");
}).pipe(
Effect.provide(