mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-10-30 09:16:55 +00:00
fix(cli): a Windows render no longer prints taskkill's already-exited message (#6698)
* fix(cli): a Windows render no longer prints taskkill's already-exited message * fix(cli): fold the taskkill note into the hidden() doc comment
This commit is contained in:
@@ -65,6 +65,15 @@ describe("hideChildConsoles", () => {
|
||||
expect(calls[3]?.at(-1)).toBe(callback);
|
||||
});
|
||||
|
||||
it("silences taskkill's stderr when its target is already gone", () => {
|
||||
const calls = run("win32", (m) => {
|
||||
m.execSync("taskkill /pid 1 /T /F");
|
||||
m.execSync("echo hi");
|
||||
});
|
||||
expect(calls[0]?.[2]).toEqual({ windowsHide: true, stdio: "ignore" });
|
||||
expect(calls[1]?.[2]).toEqual({ windowsHide: true });
|
||||
});
|
||||
|
||||
it("leaves a caller that wants the window alone", () => {
|
||||
const calls = run("win32", (m) =>
|
||||
m.spawn("browser", [], { windowsHide: false, detached: true }),
|
||||
|
||||
@@ -7,15 +7,18 @@ type ChildProcessModule = Record<string, unknown>;
|
||||
|
||||
const ENTRY_POINTS = ["spawn", "spawnSync", "exec", "execSync", "execFile", "execFileSync", "fork"];
|
||||
|
||||
/** The call's arguments with `windowsHide: true` set unless the caller chose either way. */
|
||||
/** The call's arguments with `windowsHide: true` unless the caller chose; a taskkill's stderr is dropped too. */
|
||||
function hidden(command: string, rest: unknown[]): unknown[] {
|
||||
const defaults = /^taskkill\s/i.test(command)
|
||||
? { windowsHide: true, stdio: "ignore" }
|
||||
: { windowsHide: true };
|
||||
const args = [...rest];
|
||||
const at = args.findIndex((arg) => arg && typeof arg === "object" && !Array.isArray(arg));
|
||||
if (at >= 0) {
|
||||
args[at] = { windowsHide: true, ...(args[at] as object) };
|
||||
args[at] = { ...defaults, ...(args[at] as object) };
|
||||
} else {
|
||||
const callback = args.findIndex((arg) => typeof arg === "function");
|
||||
args.splice(callback < 0 ? args.length : callback, 0, { windowsHide: true });
|
||||
args.splice(callback < 0 ? args.length : callback, 0, defaults);
|
||||
}
|
||||
return [command, ...args];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user