diff --git a/apps/desktop/scripts/utils.mjs b/apps/desktop/scripts/utils.mjs index edc66f4f8b..f695d09a91 100644 --- a/apps/desktop/scripts/utils.mjs +++ b/apps/desktop/scripts/utils.mjs @@ -1,9 +1,11 @@ +import path from 'node:path'; import { pathToFileURL } from 'node:url'; // returns true if the passsed file is being invoked from node, -// not imported. +// not imported. `node -e` / stdin runs have no argv[1]: nothing is main. /** @param {string} importMetaUrl @returns {boolean} */ export function isMain(importMetaUrl) { - return importMetaUrl === pathToFileURL(process.argv[1]).href; -} \ No newline at end of file + const entry = process.argv[1]; + return entry !== undefined && importMetaUrl === pathToFileURL(path.resolve(entry)).href; +}