blob: e53d4c9a13572d743d8535cf7dd69bee49e77d4b (
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.
|