aboutsummaryrefslogtreecommitdiff
path: root/docs/guides/util/entrypoint.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/guides/util/entrypoint.md')
-rw-r--r--docs/guides/util/entrypoint.md17
1 files changed, 17 insertions, 0 deletions
diff --git a/docs/guides/util/entrypoint.md b/docs/guides/util/entrypoint.md
new file mode 100644
index 000000000..e53d4c9a1
--- /dev/null
+++ b/docs/guides/util/entrypoint.md
@@ -0,0 +1,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.