Files
hermes-agent/apps/desktop/scripts/utils.mjs
ethernet 4920ca4160 fix(desktop): isMain returns false when there is no entry script
Importing a script from `node -e` leaves process.argv[1] undefined, and
pathToFileURL(undefined) throws on import. The bootstrap installer's
signing step imports batch-sign-binaries.mjs this way, and it crashed
when that pulled in sanitize-pe-signatures.mjs.
2026-09-24 21:22:18 -04:00

12 lines
438 B
JavaScript

import path from 'node:path';
import { pathToFileURL } from 'node:url';
// returns true if the passsed file is being invoked from node,
// not imported. `node -e` / stdin runs have no argv[1]: nothing is main.
/** @param {string} importMetaUrl @returns {boolean} */
export function isMain(importMetaUrl) {
const entry = process.argv[1];
return entry !== undefined && importMetaUrl === pathToFileURL(path.resolve(entry)).href;
}