diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2020-06-12 20:23:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-12 15:23:38 -0400 |
commit | 1fff6f55c3ba98a10018c6d374795e612061e9b6 (patch) | |
tree | 12074b6d44736b11513d857e437f9e30a6bf65a4 /std/fs/empty_dir.ts | |
parent | 26bf56afdaf16634ffbaa23684faf3a44cc10f62 (diff) |
refactor: Don't destructure the Deno namespace (#6268)
Diffstat (limited to 'std/fs/empty_dir.ts')
-rw-r--r-- | std/fs/empty_dir.ts | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/std/fs/empty_dir.ts b/std/fs/empty_dir.ts index 2f5d2deeb..dea09b5c0 100644 --- a/std/fs/empty_dir.ts +++ b/std/fs/empty_dir.ts @@ -1,6 +1,6 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { join } from "../path/mod.ts"; -const { readDir, readDirSync, mkdir, mkdirSync, remove, removeSync } = Deno; + /** * Ensures that a directory is empty. * Deletes directory contents if the directory is not empty. @@ -11,7 +11,7 @@ const { readDir, readDirSync, mkdir, mkdirSync, remove, removeSync } = Deno; export async function emptyDir(dir: string): Promise<void> { try { const items = []; - for await (const dirEntry of readDir(dir)) { + for await (const dirEntry of Deno.readDir(dir)) { items.push(dirEntry); } @@ -19,7 +19,7 @@ export async function emptyDir(dir: string): Promise<void> { const item = items.shift(); if (item && item.name) { const filepath = join(dir, item.name); - await remove(filepath, { recursive: true }); + await Deno.remove(filepath, { recursive: true }); } } } catch (err) { @@ -28,7 +28,7 @@ export async function emptyDir(dir: string): Promise<void> { } // if not exist. then create it - await mkdir(dir, { recursive: true }); + await Deno.mkdir(dir, { recursive: true }); } } @@ -41,14 +41,14 @@ export async function emptyDir(dir: string): Promise<void> { */ export function emptyDirSync(dir: string): void { try { - const items = [...readDirSync(dir)]; + const items = [...Deno.readDirSync(dir)]; // If the directory exists, remove all entries inside it. while (items.length) { const item = items.shift(); if (item && item.name) { const filepath = join(dir, item.name); - removeSync(filepath, { recursive: true }); + Deno.removeSync(filepath, { recursive: true }); } } } catch (err) { @@ -56,7 +56,7 @@ export function emptyDirSync(dir: string): void { throw err; } // if not exist. then create it - mkdirSync(dir, { recursive: true }); + Deno.mkdirSync(dir, { recursive: true }); return; } } |