summaryrefslogtreecommitdiff
path: root/std/fs/ensure_file.ts
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2020-06-12 20:23:38 +0100
committerGitHub <noreply@github.com>2020-06-12 15:23:38 -0400
commit1fff6f55c3ba98a10018c6d374795e612061e9b6 (patch)
tree12074b6d44736b11513d857e437f9e30a6bf65a4 /std/fs/ensure_file.ts
parent26bf56afdaf16634ffbaa23684faf3a44cc10f62 (diff)
refactor: Don't destructure the Deno namespace (#6268)
Diffstat (limited to 'std/fs/ensure_file.ts')
-rw-r--r--std/fs/ensure_file.ts9
1 files changed, 4 insertions, 5 deletions
diff --git a/std/fs/ensure_file.ts b/std/fs/ensure_file.ts
index a1476b657..b36379b3d 100644
--- a/std/fs/ensure_file.ts
+++ b/std/fs/ensure_file.ts
@@ -2,7 +2,6 @@
import * as path from "../path/mod.ts";
import { ensureDir, ensureDirSync } from "./ensure_dir.ts";
import { getFileInfoType } from "./_util.ts";
-const { lstat, lstatSync, writeFile, writeFileSync } = Deno;
/**
* Ensures that the file exists.
@@ -15,7 +14,7 @@ const { lstat, lstatSync, writeFile, writeFileSync } = Deno;
export async function ensureFile(filePath: string): Promise<void> {
try {
// if file exists
- const stat = await lstat(filePath);
+ const stat = await Deno.lstat(filePath);
if (!stat.isFile) {
throw new Error(
`Ensure path exists, expected 'file', got '${getFileInfoType(stat)}'`
@@ -27,7 +26,7 @@ export async function ensureFile(filePath: string): Promise<void> {
// ensure dir exists
await ensureDir(path.dirname(filePath));
// create file
- await writeFile(filePath, new Uint8Array());
+ await Deno.writeFile(filePath, new Uint8Array());
return;
}
@@ -46,7 +45,7 @@ export async function ensureFile(filePath: string): Promise<void> {
export function ensureFileSync(filePath: string): void {
try {
// if file exists
- const stat = lstatSync(filePath);
+ const stat = Deno.lstatSync(filePath);
if (!stat.isFile) {
throw new Error(
`Ensure path exists, expected 'file', got '${getFileInfoType(stat)}'`
@@ -58,7 +57,7 @@ export function ensureFileSync(filePath: string): void {
// ensure dir exists
ensureDirSync(path.dirname(filePath));
// create file
- writeFileSync(filePath, new Uint8Array());
+ Deno.writeFileSync(filePath, new Uint8Array());
return;
}
throw err;