fix(dev): resolve taskkill in tui pty watcher

This commit is contained in:
Vincent Koc
2026-06-21 10:01:01 +02:00
parent 0321c04663
commit ac0537e363
2 changed files with 25 additions and 9 deletions
+2 -1
View File
@@ -4,6 +4,7 @@ import { mkdir, open, writeFile } from "node:fs/promises";
import { createRequire } from "node:module";
import path from "node:path";
import { pathToFileURL } from "node:url";
import { resolveWindowsTaskkillPath } from "../lib/windows-taskkill.mjs";
type Options = {
altScreen: boolean;
@@ -146,7 +147,7 @@ function signalWindowsProcessTree(
if (signal === "SIGKILL") {
args.push("/F");
}
const result = runTaskkill("taskkill", args, { stdio: "ignore" });
const result = runTaskkill(resolveWindowsTaskkillPath(), args, { stdio: "ignore" });
return !result?.error && result?.status === 0;
}
+23 -8
View File
@@ -21,9 +21,14 @@ import {
redactHomePath,
redactJsonValueForDevToolLog,
} from "../../scripts/lib/dev-tooling-safety.ts";
import { resolveWindowsTaskkillPath } from "../../scripts/lib/windows-taskkill.mjs";
const tempDirs: string[] = [];
function expectedTaskkillPath(): string {
return resolveWindowsTaskkillPath();
}
async function waitForCondition(predicate: () => boolean, timeoutMs = 5_000): Promise<void> {
const started = Date.now();
while (Date.now() - started < timeoutMs) {
@@ -476,7 +481,7 @@ describe("script-specific dev tooling hardening", () => {
platform: "win32",
runTaskkill,
});
expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "123", "/T"], {
expect(runTaskkill).toHaveBeenNthCalledWith(1, expectedTaskkillPath(), ["/PID", "123", "/T"], {
stdio: "ignore",
});
@@ -484,9 +489,14 @@ describe("script-specific dev tooling hardening", () => {
platform: "win32",
runTaskkill,
});
expect(runTaskkill).toHaveBeenNthCalledWith(2, "taskkill", ["/PID", "123", "/T", "/F"], {
stdio: "ignore",
});
expect(runTaskkill).toHaveBeenNthCalledWith(
2,
expectedTaskkillPath(),
["/PID", "123", "/T", "/F"],
{
stdio: "ignore",
},
);
expect(childKill).not.toHaveBeenCalled();
});
@@ -502,12 +512,17 @@ describe("script-specific dev tooling hardening", () => {
runTaskkill,
});
expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "123", "/T"], {
stdio: "ignore",
});
expect(runTaskkill).toHaveBeenNthCalledWith(2, "taskkill", ["/PID", "123", "/T", "/F"], {
expect(runTaskkill).toHaveBeenNthCalledWith(1, expectedTaskkillPath(), ["/PID", "123", "/T"], {
stdio: "ignore",
});
expect(runTaskkill).toHaveBeenNthCalledWith(
2,
expectedTaskkillPath(),
["/PID", "123", "/T", "/F"],
{
stdio: "ignore",
},
);
expect(childKill).not.toHaveBeenCalled();
});