refactor: centralize strict numeric parsing

This commit is contained in:
Peter Steinberger
2026-03-08 02:52:44 +00:00
parent 3087893ef9
commit 2646739d23
11 changed files with 128 additions and 30 deletions

View File

@@ -122,6 +122,19 @@ describe("launchd runtime parsing", () => {
expect(info.pid).toBeUndefined();
expect(info.state).toBe("waiting");
});
it("rejects pid and exit status values with junk suffixes", () => {
const output = [
"state = waiting",
"pid = 123abc",
"last exit status = 7ms",
"last exit reason = exited",
].join("\n");
expect(parseLaunchctlPrint(output)).toEqual({
state: "waiting",
lastExitReason: "exited",
});
});
});
describe("launchctl list detection", () => {