How do I check whether a folder already exists using Bun?
I tried the following without success:
const path = "folderName"
const file = Bun.file(path)
await file.exists()
Based on the guide for working with files: https://bun.sh/guides/read-file/exists
I know it's for checking whether a file exists, but usually you can do the same thing for folders.
I checked that the path is correct by referring for a file inside the folder folderName/fileName
, and it worked.
How do I check whether a folder already exists with Bun?
To test if a file/folder exist , you can use :
If you want to know if it's a folder and not a file, you can compare with the scanSync without option