summaryrefslogtreecommitdiff
path: root/std/fs/exists.ts
diff options
context:
space:
mode:
Diffstat (limited to 'std/fs/exists.ts')
-rw-r--r--std/fs/exists.ts17
1 files changed, 9 insertions, 8 deletions
diff --git a/std/fs/exists.ts b/std/fs/exists.ts
index ae64cb1f3..f9e5a0925 100644
--- a/std/fs/exists.ts
+++ b/std/fs/exists.ts
@@ -4,15 +4,16 @@ const { lstat, lstatSync } = Deno;
* Test whether or not the given path exists by checking with the file system
*/
export async function exists(filePath: string): Promise<boolean> {
- return lstat(filePath)
- .then((): boolean => true)
- .catch((err: Error): boolean => {
- if (err instanceof Deno.errors.NotFound) {
- return false;
- }
+ try {
+ await lstat(filePath);
+ return true;
+ } catch (err) {
+ if (err instanceof Deno.errors.NotFound) {
+ return false;
+ }
- throw err;
- });
+ throw err;
+ }
}
/**