diff --git a/cli/tests/unit/command_test.ts b/cli/tests/unit/command_test.ts index 1c707651c5..cbb1c4921c 100644 --- a/cli/tests/unit/command_test.ts +++ b/cli/tests/unit/command_test.ts @@ -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(), { diff --git a/cli/tests/unit/process_test.ts b/cli/tests/unit/process_test.ts index f6ad2a5cd6..cb5dd08154 100644 --- a/cli/tests/unit/process_test.ts +++ b/cli/tests/unit/process_test.ts @@ -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 diff --git a/cli/tests/unit_node/_fs/_fs_ftruncate_test.ts b/cli/tests/unit_node/_fs/_fs_ftruncate_test.ts index a843b19b74..4c2c347892 100644 --- a/cli/tests/unit_node/_fs/_fs_ftruncate_test.ts +++ b/cli/tests/unit_node/_fs/_fs_ftruncate_test.ts @@ -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, diff --git a/cli/tests/unit_node/_fs/_fs_truncate_test.ts b/cli/tests/unit_node/_fs/_fs_truncate_test.ts index 00e03ab0e1..ff087095be 100644 --- a/cli/tests/unit_node/_fs/_fs_truncate_test.ts +++ b/cli/tests/unit_node/_fs/_fs_truncate_test.ts @@ -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((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((resolve, reject) => { truncate(file, 3, (err: Error | null) => { diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts index 4107e13693..f17f9088dc 100644 --- a/cli/tsc/dts/lib.deno.ns.d.ts +++ b/cli/tsc/dts/lib.deno.ns.d.ts @@ -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"