summaryrefslogtreecommitdiff
path: root/testdata/read_file_sync.ts
diff options
context:
space:
mode:
Diffstat (limited to 'testdata/read_file_sync.ts')
-rw-r--r--testdata/read_file_sync.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/testdata/read_file_sync.ts b/testdata/read_file_sync.ts
new file mode 100644
index 000000000..cb0904d35
--- /dev/null
+++ b/testdata/read_file_sync.ts
@@ -0,0 +1,14 @@
+import { readFileSync } from "deno";
+
+let data = readFileSync("package.json");
+if (!data.byteLength) {
+ throw Error(`Expected positive value for data.byteLength ${data.byteLength}`);
+}
+
+const decoder = new TextDecoder("utf-8");
+const json = decoder.decode(data);
+const pkg = JSON.parse(json);
+if (pkg.name !== "deno") {
+ throw Error(`Expected "deno" but got "${pkg.name}"`)
+}
+console.log("package.name ", pkg.name);