Skip to content
Warlock.js v4

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 recursive option from node:fs/promises).

Install with your package manager:

Terminal window
yarn add @warlock.js/fs

Then import what you need — no setup, no factory, no config:

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

Every export is tree-shakeable. Pull in hashString alone and you’re not bundling the directory helpers.

Types ship with the package — no separate @types/... install. Every helper is fully typed; the JSON helpers are generic:

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

If you skip the generic, you get unknown — narrow it with a guard before reading fields.

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

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

If that prints ok, you’re done.