summaryrefslogtreecommitdiff
path: root/std/fs/exists.ts
diff options
context:
space:
mode:
authorSamrith Shankar <samrith-s@users.noreply.github.com>2020-03-20 14:38:34 +0100
committerGitHub <noreply@github.com>2020-03-20 09:38:34 -0400
commit798904b0f2ed0c7284b67bba2f125f406b5850de (patch)
tree5aba8d35aa8984aa778c894258bcaed56f1ce17c /std/fs/exists.ts
parent35f6e2e45ddb96524a6bdf54b0a6155caa88d5e0 (diff)
Add require-await lint rule (#4401)
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;
+ }
}
/**