Skip to content

isMainModule

function isMainModule(meta): boolean;

Defined in: src/cli/index.ts:704

The self-run guard (au 6761a34): true when the module is the program’s entry point (bun src/cli.ts, node dist/cli.mjs), false when it is imported — by the bin/ wrapper, a test or the standalone app — so run() executes exactly once.

src/cli.ts
export async function run(argv: string[]): Promise<number> { … }
if (isMainModule(import.meta.url)) run(process.argv.slice(2)).then((code) => process.exit(code));
Parameter Type
meta | string | { main?: boolean; url: string; }

boolean