summaryrefslogtreecommitdiff
path: root/testdata/read_file_sync.ts
blob: cb0904d3577e1932518648bff9d23a6cd1e5c8e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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);