From 798904b0f2ed0c7284b67bba2f125f406b5850de Mon Sep 17 00:00:00 2001 From: Samrith Shankar Date: Fri, 20 Mar 2020 14:38:34 +0100 Subject: Add require-await lint rule (#4401) --- std/fs/copy_test.ts | 5 +---- std/fs/exists.ts | 17 +++++++++-------- std/fs/walk_test.ts | 4 ++-- 3 files changed, 12 insertions(+), 14 deletions(-) (limited to 'std/fs') diff --git a/std/fs/copy_test.ts b/std/fs/copy_test.ts index fb8827f0c..9ba5f2b21 100644 --- a/std/fs/copy_test.ts +++ b/std/fs/copy_test.ts @@ -17,10 +17,7 @@ const testdataDir = path.resolve("fs", "testdata"); // TODO(axetroy): Add test for Windows once symlink is implemented for Windows. const isWindows = Deno.build.os === "win"; -async function testCopy( - name: string, - cb: (tempDir: string) => Promise -): Promise { +function testCopy(name: string, cb: (tempDir: string) => Promise): void { Deno.test({ name, async fn(): Promise { 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 { - 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; + } } /** diff --git a/std/fs/walk_test.ts b/std/fs/walk_test.ts index c2518cee3..96bfcae67 100644 --- a/std/fs/walk_test.ts +++ b/std/fs/walk_test.ts @@ -5,11 +5,11 @@ import { assert, assertEquals, assertThrowsAsync } from "../testing/asserts.ts"; const isWindows = Deno.build.os == "win"; -export async function testWalk( +export function testWalk( setup: (arg0: string) => void | Promise, t: Deno.TestFunction, ignore = false -): Promise { +): void { const name = t.name; async function fn(): Promise { const origCwd = cwd(); -- cgit v1.2.3