Merge pull request #122095 from NousResearch/fix/desktop-ismain-eval

fix(desktop): isMain returns false when there is no entry script
This commit is contained in:
ethernet
2026-09-24 21:35:02 -04:00
committed by GitHub

View File

@@ -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;
}
const entry = process.argv[1];
return entry !== undefined && importMetaUrl === pathToFileURL(path.resolve(entry)).href;
}