mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
chore: use Deno.writeTextFile()
where appropriate (#22008)
This commit is contained in:
parent
1b9f0cb452
commit
e58462dbb9
5 changed files with 7 additions and 9 deletions
|
@ -208,8 +208,7 @@ Deno.test(
|
|||
async function commandRedirectStdin() {
|
||||
const tempDir = await Deno.makeTempDir();
|
||||
const fileName = tempDir + "/redirected_stdio.txt";
|
||||
const encoder = new TextEncoder();
|
||||
await Deno.writeFile(fileName, encoder.encode("hello"));
|
||||
await Deno.writeTextFile(fileName, "hello");
|
||||
const file = await Deno.open(fileName);
|
||||
|
||||
const command = new Deno.Command(Deno.execPath(), {
|
||||
|
|
|
@ -395,8 +395,7 @@ Deno.test(
|
|||
async function runRedirectStdin() {
|
||||
const tempDir = await Deno.makeTempDir();
|
||||
const fileName = tempDir + "/redirected_stdio.txt";
|
||||
const encoder = new TextEncoder();
|
||||
await Deno.writeFile(fileName, encoder.encode("hello"));
|
||||
await Deno.writeTextFile(fileName, "hello");
|
||||
const file = await Deno.open(fileName);
|
||||
|
||||
// deno-lint-ignore no-deprecated-deno-api
|
||||
|
|
|
@ -24,7 +24,7 @@ Deno.test({
|
|||
name: "ASYNC: truncate entire file contents",
|
||||
async fn() {
|
||||
const file: string = Deno.makeTempFileSync();
|
||||
await Deno.writeFile(file, new TextEncoder().encode("hello world"));
|
||||
await Deno.writeTextFile(file, "hello world");
|
||||
const { rid } = await Deno.open(file, {
|
||||
read: true,
|
||||
write: true,
|
||||
|
@ -57,7 +57,7 @@ Deno.test({
|
|||
name: "ASYNC: truncate file to a size of precisely len bytes",
|
||||
async fn() {
|
||||
const file: string = Deno.makeTempFileSync();
|
||||
await Deno.writeFile(file, new TextEncoder().encode("hello world"));
|
||||
await Deno.writeTextFile(file, "hello world");
|
||||
const { rid } = await Deno.open(file, {
|
||||
read: true,
|
||||
write: true,
|
||||
|
|
|
@ -24,7 +24,7 @@ Deno.test({
|
|||
name: "ASYNC: truncate entire file contents",
|
||||
async fn() {
|
||||
const file: string = Deno.makeTempFileSync();
|
||||
await Deno.writeFile(file, new TextEncoder().encode("hello world"));
|
||||
await Deno.writeTextFile(file, "hello world");
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
truncate(file, (err: Error | null) => {
|
||||
|
@ -49,7 +49,7 @@ Deno.test({
|
|||
name: "ASYNC: truncate file to a size of precisely len bytes",
|
||||
async fn() {
|
||||
const file: string = Deno.makeTempFileSync();
|
||||
await Deno.writeFile(file, new TextEncoder().encode("hello world"));
|
||||
await Deno.writeTextFile(file, "hello world");
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
truncate(file, 3, (err: Error | null) => {
|
||||
|
|
2
cli/tsc/dts/lib.deno.ns.d.ts
vendored
2
cli/tsc/dts/lib.deno.ns.d.ts
vendored
|
@ -3717,7 +3717,7 @@ declare namespace Deno {
|
|||
*
|
||||
* ```ts
|
||||
* const file = await Deno.makeTempFile();
|
||||
* await Deno.writeFile(file, new TextEncoder().encode("Hello World"));
|
||||
* await Deno.writeTextFile(file, "Hello World");
|
||||
* await Deno.truncate(file, 7);
|
||||
* const data = await Deno.readFile(file);
|
||||
* console.log(new TextDecoder().decode(data)); // "Hello W"
|
||||
|
|
Loading…
Reference in a new issue