檢查檔案是否存在
Bun.file() 函式接受一個路徑並傳回一個 BunFile 例項。使用 .exists() 方法可以檢查給定路徑下的檔案是否存在。
const path = "/path/to/package.json";
const file = Bun.file(path);
await file.exists(); // 布林值;
請參閱檔案 I/O,瞭解有關使用 BunFile 的更多資訊。
Bun.file() 函式接受一個路徑並傳回一個 BunFile 例項。使用 .exists() 方法可以檢查給定路徑下的檔案是否存在。
const path = "/path/to/package.json";
const file = Bun.file(path);
await file.exists(); // 布林值;
請參閱檔案 I/O,瞭解有關使用 BunFile 的更多資訊。