Files
ps5upload/scripts/stale-client-lib.test.mjs
T
phantomptrandClaude Opus 5.5 0bba2cbab8 fix(scripts): make run-client stops only the engine on the app's port
kill-stale-client did `pkill -f ps5upload-engine`, which SIGTERMed
every engine on the machine — a standalone one on another port died 70
minutes into a package build. It now stops only an engine listening on
19113 (an engine whose app is gone exits by itself). The decision is a
small pure module with node:test cases, which scripts:check now runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 12:23:54 -07:00

22 lines
889 B
JavaScript

import assert from "node:assert/strict";
import { test } from "node:test";
import { staleEnginePids } from "./stale-client-lib.mjs";
test("only the engine holding the app's port is stale", () => {
const listeners = [
{ pid: 10, command: "/Users/me/Library/Application Support/com.phantomptr.ps5upload/engine/ps5upload-engine" },
{ pid: 11, command: "/usr/bin/python3 -m http.server 19113" },
];
assert.deepEqual(staleEnginePids(listeners), [10]);
});
test("an engine elsewhere — a conversion on another port — is never in the list to kill", () => {
// The caller passes only what listens on the app's port; nothing else can come back.
assert.deepEqual(staleEnginePids([]), []);
});
test("a name that merely contains the words is not the engine", () => {
assert.deepEqual(staleEnginePids([{ pid: 12, command: "vim notes-about-ps5upload-engine.txt" }]), []);
});