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

await file.exists(); // boolean;

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