battlelog/lib/fileExists.ts

15 lines
367 B
TypeScript

export const fileExists = async (path: string) => {
try {
await Deno.stat(path);
return true;
} catch (error) {
if (error instanceof Deno.errors.NotFound) {
// file or directory does not exist
// console.log(error);
return false;
} else {
// unexpected error, maybe permissions, pass it along
throw error;
}
}
}