A Nano Tool for Reading
and Writing
JSON.
pnpm i @bit2byte/nano-json
import path from "path";
import { PackageJson } from "type-fest";
import NanoJson from "@bit2byte/nano-json";
const pkg = new NanoJson<PackageJson>(path.join(__dirname, "./package.json"));
// read
await pkg.r();
if (pkg.d) {
// edit
pkg.d.version = "1.0.0";
}
// write
await pkg.w();
Inspired by @srzorro/file-json