summaryrefslogtreecommitdiff
path: root/cli/js/write_text_file.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/js/write_text_file.ts')
-rw-r--r--cli/js/write_text_file.ts10
1 files changed, 6 insertions, 4 deletions
diff --git a/cli/js/write_text_file.ts b/cli/js/write_text_file.ts
index 4f111edb4..615813460 100644
--- a/cli/js/write_text_file.ts
+++ b/cli/js/write_text_file.ts
@@ -1,10 +1,12 @@
+// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+
import { open, openSync } from "./files.ts";
import { writeAll, writeAllSync } from "./buffer.ts";
export function writeTextFileSync(path: string | URL, data: string): void {
const file = openSync(path, { write: true, create: true, truncate: true });
- const enc = new TextEncoder();
- const contents = enc.encode(data);
+ const encoder = new TextEncoder();
+ const contents = encoder.encode(data);
writeAllSync(file, contents);
file.close();
}
@@ -14,8 +16,8 @@ export async function writeTextFile(
data: string
): Promise<void> {
const file = await open(path, { write: true, create: true, truncate: true });
- const enc = new TextEncoder();
- const contents = enc.encode(data);
+ const encoder = new TextEncoder();
+ const contents = encoder.encode(data);
await writeAll(file, contents);
file.close();
}