summaryrefslogtreecommitdiff
path: root/std/fs/ensure_file.ts
diff options
context:
space:
mode:
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;