AgentSkillsCN

Bun Get the absolute path to the current entrypoint

获取当前入口文件的绝对路径

SKILL.md
--- frontmatter
name: Bun Get the absolute path to the current entrypoint
description: Get the absolute path to the current entrypoint

Get the absolute path to the current entrypoint

The Bun.main property contains the absolute path to the current entrypoint.

<CodeGroup> ```ts foo.ts icon="https://mintcdn.com/bun-1dd33a4e/nIz6GtMH5K-dfXeV/icons/typescript.svg?fit=max&auto=format&n=nIz6GtMH5K-dfXeV&q=85&s=5d73d76daf7eb7b158469d8c30d349b0" theme={"theme":{"light":"github-light","dark":"dracula"}} console.log(Bun.main); ```
ts
import "./foo.ts";
</CodeGroup>

The printed path corresponds to the file that is executed with bun run.

sh
bun run index.ts
txt
/path/to/index.ts
sh
bun run foo.ts
txt
/path/to/foo.ts

See Docs > API > Utils for more useful utilities.