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

await file.exists(); // boolean;

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