diff options
Diffstat (limited to 'std/fs')
-rw-r--r-- | std/fs/copy_test.ts | 5 | ||||
-rw-r--r-- | std/fs/exists.ts | 17 | ||||
-rw-r--r-- | std/fs/walk_test.ts | 4 |
3 files changed, 12 insertions, 14 deletions
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<void> -): Promise<void> { +function testCopy(name: string, cb: (tempDir: string) => Promise<void>): void { Deno.test({ name, async fn(): Promise<void> { 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; + } } /** 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<void>, t: Deno.TestFunction, ignore = false -): Promise<void> { +): void { const name = t.name; async function fn(): Promise<void> { const origCwd = cwd(); |