1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-29 02:29:06 -05:00
denoland-deno/fs/exists.ts

19 lines
534 B
TypeScript
Raw Normal View History

2019-03-11 13:14:26 -04:00
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
2019-03-14 10:24:54 -04:00
/** Test whether or not the given path exists by checking with the file system */
2019-03-11 13:14:26 -04:00
export async function exists(filePath: string): Promise<boolean> {
return Deno.lstat(filePath)
2019-03-11 13:14:26 -04:00
.then(() => true)
.catch(() => false);
}
2019-03-14 10:24:54 -04:00
/** Test whether or not the given path exists by checking with the file system */
2019-03-11 13:14:26 -04:00
export function existsSync(filePath: string): boolean {
try {
Deno.lstatSync(filePath);
2019-03-11 13:14:26 -04:00
return true;
} catch {
return false;
}
}