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/ensure_dir.ts | |
parent | 26bf56afdaf16634ffbaa23684faf3a44cc10f62 (diff) |
refactor: Don't destructure the Deno namespace (#6268)
Diffstat (limited to 'std/fs/ensure_dir.ts')
-rw-r--r-- | std/fs/ensure_dir.ts | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/std/fs/ensure_dir.ts b/std/fs/ensure_dir.ts index 43b230ae1..961476028 100644 --- a/std/fs/ensure_dir.ts +++ b/std/fs/ensure_dir.ts @@ -1,6 +1,5 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { getFileInfoType } from "./_util.ts"; -const { lstat, lstatSync, mkdir, mkdirSync } = Deno; /** * Ensures that the directory exists. @@ -9,7 +8,7 @@ const { lstat, lstatSync, mkdir, mkdirSync } = Deno; */ export async function ensureDir(dir: string): Promise<void> { try { - const fileInfo = await lstat(dir); + const fileInfo = await Deno.lstat(dir); if (!fileInfo.isDirectory) { throw new Error( `Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'` @@ -18,7 +17,7 @@ export async function ensureDir(dir: string): Promise<void> { } catch (err) { if (err instanceof Deno.errors.NotFound) { // if dir not exists. then create it. - await mkdir(dir, { recursive: true }); + await Deno.mkdir(dir, { recursive: true }); return; } throw err; @@ -32,7 +31,7 @@ export async function ensureDir(dir: string): Promise<void> { */ export function ensureDirSync(dir: string): void { try { - const fileInfo = lstatSync(dir); + const fileInfo = Deno.lstatSync(dir); if (!fileInfo.isDirectory) { throw new Error( `Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'` @@ -41,7 +40,7 @@ export function ensureDirSync(dir: string): void { } catch (err) { if (err instanceof Deno.errors.NotFound) { // if dir not exists. then create it. - mkdirSync(dir, { recursive: true }); + Deno.mkdirSync(dir, { recursive: true }); return; } throw err; |