blob: 63d71b63045c33b61e9569a13f0601a4db45eb3d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
---
name: Check if the current file is the entrypoint
---
Bun provides a handful of module-specific utilities on the [`import.meta`](/docs/api/import-meta) object. Use `import.meta.main` to check if the current file is the entrypoint of the current process.
```ts#index.ts
if (import.meta.main) {
// this file is directly executed with `bun run`
} else {
// this file is being imported by another file
}
```
---
See [Docs > API > import.meta](/docs/api/import-meta) for complete documentation.
|