mirror of
https://github.com/denoland/deno.git
synced 2025-09-30 06:04:48 +00:00
clean up code in cli/js (#6611)
This commit is contained in:
parent
ab4c574f52
commit
158ae0bfe9
89 changed files with 395 additions and 354 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue