1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-12 09:03:42 -05:00
denoland-deno/tests/read_file_sync.ts
2018-08-09 14:27:46 -07:00

18 lines
631 B
TypeScript

// TODO(ry) Once unit_tests.js lands (#448) this file should be removed
// and replaced with a faster version like was done in the prototype.
// https://github.com/denoland/deno/blob/golang/tests.ts#L34-L45
import * as deno from "deno";
const data = deno.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['devDependencies'] == null) {
throw Error("Expected a positive number of devDependencies");
}
console.log("ok");