Skip to main content
Bun.file() 函数接受一个路径并返回一个 BunFile 实例。使用 .exists() 方法可以检查给定路径下的文件是否存在。
https://mintcdn.com/bun-zhcndoc/cnUTwgMuf4cCrwC-/icons/typescript.svg?fit=max&auto=format&n=cnUTwgMuf4cCrwC-&q=85&s=e7767043c9e885c34f2d6c8fe2a95217index.ts
const path = "/path/to/package.json";
const file = Bun.file(path);

await file.exists(); // boolean;

有关使用 BunFile 的更多信息,请参见 API > 文件 I/O