Skip to content
Warlock.js v4.7.0

Installation

@warlock.js/fs is standalone. It has no runtime dependencies beyond Node’s built-in node:fs and node:crypto. Requires Node 18 or newer (uses cp with the recursive option from node:fs/promises).

Install with your package manager:

Terminal window
yarn add @warlock.js/fs

Then import the fs object — no setup, no factory, no config:

import { fs } from "@warlock.js/fs";
await fs.files.putJson("./out/manifest.json", { version: "1.0.0" });
const manifest = await fs.files.getJson<{ version: string }>("./out/manifest.json");

That’s the whole entry point: one import, and the entire filesystem toolkit is on fs.

Types ship with the package — no separate @types/... install. Every method is fully typed, and the JSON reads are generic:

type Manifest = { version: string; files: string[] };
const manifest = await fs.files.getJson<Manifest>("./manifest.json");
// ^? Manifest

Skip the generic and you get unknown — narrow it with a guard, or pass a schema to getJson to validate and type in one step (see Read and write files).

A one-liner to prove it’s wired up:

import { fs } from "@warlock.js/fs";
await fs.files.put("./.fs-check", "ok");
console.log(await fs.files.get("./.fs-check")); // → "ok"

If that prints ok, you’re done.

  • Your first write — write JSON, read it back typed, and grab a lazy file handle, all through the fs facade.