fix(process): normalize macOS launcher identity

This commit is contained in:
morluto
2026-07-24 03:38:25 +00:00
parent 13f3372a8b
commit 9c3aec8131
3 changed files with 53 additions and 9 deletions
+24
View File
@@ -0,0 +1,24 @@
import { basename } from "node:path";
/** Match process-table command text while handling macOS executable-name normalization. */
export const matchesOwnedProcessCommand = (
actual: string,
expected: string,
platform: NodeJS.Platform = process.platform,
): boolean => {
const actualCommand = actual.trim();
const expectedCommand = expected.trim();
if (
actualCommand === expectedCommand ||
actualCommand.startsWith(`${expectedCommand} `)
)
return true;
if (platform !== "darwin") return false;
const actualExecutable = actualCommand.split(/\s+/u, 1)[0];
const expectedExecutable = expectedCommand.split(/\s+/u, 1)[0];
return (
actualExecutable !== undefined &&
expectedExecutable !== undefined &&
basename(actualExecutable) === basename(expectedExecutable)
);
};