Skip to content

The agent that grows with you

fix(desktop): isMain returns false when there is no entry script

ethernet4920ca416014
diff --git a/apps/desktop/scripts/utils.mjs b/apps/desktop/scripts/utils.mjs
index edc66f4f8bf..f695d09a913 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;
+}