fix(process): normalize macOS launcher identity
This commit is contained in:
@@ -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)
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user