summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsher Gomez <ashersaupingomez@gmail.com>2024-01-22 09:41:28 +1100
committerGitHub <noreply@github.com>2024-01-21 23:41:28 +0100
commit35fc6f3ab91a9f9fdecff5072677f12cde295f3a (patch)
tree93ad7a3e05b945262ad1da19f50f052d1e420347
parentfbfeedb68b593d0dbf3f0bfb0061939756da20b7 (diff)
chore: use `Deno.readTextFile()` where appropriate (#22018)
-rw-r--r--cli/tests/unit/link_test.ts16
-rw-r--r--cli/tsc/dts/lib.deno.ns.d.ts8
2 files changed, 12 insertions, 12 deletions
diff --git a/cli/tests/unit/link_test.ts b/cli/tests/unit/link_test.ts
index 8dbea0e09..6048b8add 100644
--- a/cli/tests/unit/link_test.ts
+++ b/cli/tests/unit/link_test.ts
@@ -17,21 +17,21 @@ Deno.test(
// Create the hard link.
Deno.linkSync(oldName, newName);
// We should expect reading the same content.
- const newData = new TextDecoder().decode(Deno.readFileSync(newName));
+ const newData = Deno.readTextFileSync(newName);
assertEquals(oldData, newData);
// Writing to newname also affects oldname.
const newData2 = "Modified";
Deno.writeFileSync(newName, new TextEncoder().encode(newData2));
assertEquals(
newData2,
- new TextDecoder().decode(Deno.readFileSync(oldName)),
+ Deno.readTextFileSync(oldName),
);
// Writing to oldname also affects newname.
const newData3 = "ModifiedAgain";
Deno.writeFileSync(oldName, new TextEncoder().encode(newData3));
assertEquals(
newData3,
- new TextDecoder().decode(Deno.readFileSync(newName)),
+ Deno.readTextFileSync(newName),
);
// Remove oldname. File still accessible through newname.
Deno.removeSync(oldName);
@@ -40,7 +40,7 @@ Deno.test(
assert(!newNameStat.isSymlink); // Not a symlink.
assertEquals(
newData3,
- new TextDecoder().decode(Deno.readFileSync(newName)),
+ Deno.readTextFileSync(newName),
);
},
);
@@ -111,21 +111,21 @@ Deno.test(
// Create the hard link.
await Deno.link(oldName, newName);
// We should expect reading the same content.
- const newData = new TextDecoder().decode(Deno.readFileSync(newName));
+ const newData = Deno.readTextFileSync(newName);
assertEquals(oldData, newData);
// Writing to newname also affects oldname.
const newData2 = "Modified";
Deno.writeFileSync(newName, new TextEncoder().encode(newData2));
assertEquals(
newData2,
- new TextDecoder().decode(Deno.readFileSync(oldName)),
+ Deno.readTextFileSync(oldName),
);
// Writing to oldname also affects newname.
const newData3 = "ModifiedAgain";
Deno.writeFileSync(oldName, new TextEncoder().encode(newData3));
assertEquals(
newData3,
- new TextDecoder().decode(Deno.readFileSync(newName)),
+ Deno.readTextFileSync(newName),
);
// Remove oldname. File still accessible through newname.
Deno.removeSync(oldName);
@@ -134,7 +134,7 @@ Deno.test(
assert(!newNameStat.isSymlink); // Not a symlink.
assertEquals(
newData3,
- new TextDecoder().decode(Deno.readFileSync(newName)),
+ Deno.readTextFileSync(newName),
);
},
);
diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts
index f17f9088d..af427fda2 100644
--- a/cli/tsc/dts/lib.deno.ns.d.ts
+++ b/cli/tsc/dts/lib.deno.ns.d.ts
@@ -2122,7 +2122,7 @@ declare namespace Deno {
* await Deno.write(file.rid, new TextEncoder().encode("Hello World"));
* await Deno.ftruncate(file.rid, 1);
* await Deno.fsync(file.rid);
- * console.log(new TextDecoder().decode(await Deno.readFile("my_file.txt"))); // H
+ * console.log(await Deno.readTextFile("my_file.txt")); // H
* ```
*
* @category I/O
@@ -2141,7 +2141,7 @@ declare namespace Deno {
* Deno.writeSync(file.rid, new TextEncoder().encode("Hello World"));
* Deno.ftruncateSync(file.rid, 1);
* Deno.fsyncSync(file.rid);
- * console.log(new TextDecoder().decode(Deno.readFileSync("my_file.txt"))); // H
+ * console.log(Deno.readTextFileSync("my_file.txt")); // H
* ```
*
* @category I/O
@@ -2157,7 +2157,7 @@ declare namespace Deno {
* );
* await Deno.write(file.rid, new TextEncoder().encode("Hello World"));
* await Deno.fdatasync(file.rid);
- * console.log(new TextDecoder().decode(await Deno.readFile("my_file.txt"))); // Hello World
+ * console.log(await Deno.readTextFile("my_file.txt")); // Hello World
* ```
*
* @category I/O
@@ -2175,7 +2175,7 @@ declare namespace Deno {
* );
* Deno.writeSync(file.rid, new TextEncoder().encode("Hello World"));
* Deno.fdatasyncSync(file.rid);
- * console.log(new TextDecoder().decode(Deno.readFileSync("my_file.txt"))); // Hello World
+ * console.log(Deno.readTextFileSync("my_file.txt")); // Hello World
* ```
*
* @category I/O