ProvenPin Install

fs-extra json roundtrip, copy and move: working versions (tested 2026-10-16)

Build a temp tree with fs-extra ensureDir, writeJson/readJson, copy, move, pathExists and remove, asserting JSON roundtrip and updated paths offline.

passed3 passed · 0 failed2026-10-16 17:50 UTC
Status
passed
Last passed
2026-10-16 17:50 UTC
Tests
3 / 3
Language
TypeScript
Runtime
node v22.23.3
pinned versions4
fs-extra@11.4.1@types/fs-extra@11.0.4@types/node@26.6.5tsx@4.23.15
run it
npm install --no-audit --no-fund --ignore-scripts=false
npm test
test environment
node v22.23.3
linux 6.17.0-1022-azure
x64
runner: github-actions 38942732901

The code

Exactly the files that passed. Your agent can pull them with get_recipe("fs-extra-json-copy") (install), or see them on GitHub.

package.json
{
  "name": "fs-extra-json-copy",
  "private": true,
  "type": "module",
  "scripts": {
    "test": "node --import tsx --test test/*.test.ts"
  },
  "dependencies": {
    "fs-extra": "11.4.1"
  },
  "devDependencies": {
    "@types/fs-extra": "11.0.4",
    "@types/node": "26.6.5",
    "tsx": "4.23.15"
  }
}
src/tree.ts
import fs from "fs-extra";
import os from "node:os";
import path from "node:path";

export type Config = {
  name: string;
  version: number;
  tags: string[];
};

export async function makeTempDir(prefix = "fsx-"): Promise<string> {
  return fs.mkdtemp(path.join(os.tmpdir(), prefix));
}

export async function createTree(
  base: string,
): Promise<{ sourceDir: string; configPath: string }> {
  const sourceDir = path.join(base, "source");
  const configPath = path.join(sourceDir, "config.json");
  await fs.ensureDir(sourceDir);
  const config: Config = { name: "provenpin", version: 1, tags: ["a", "b"] };
  await fs.writeJson(configPath, config);
  return { sourceDir, configPath };
}

export async function readConfig(configPath: string): Promise<Config> {
  return (await fs.readJson(configPath)) as Config;
}

export async function copyTree(from: string, to: string): Promise<void> {
  await fs.copy(from, to);
}

export async function moveTree(from: string, to: string): Promise<void> {
  await fs.move(from, to, { overwrite: true });
}

export async function exists(target: string): Promise<boolean> {
  return fs.pathExists(target);
}

export async function removeTree(target: string): Promise<void> {
  await fs.remove(target);
}
test/tree.test.ts
import { test } from "node:test";
import assert from "node:assert/strict";
import path from "node:path";
import {
  createTree,
  readConfig,
  copyTree,
  moveTree,
  exists,
  removeTree,
  makeTempDir,
} from "../src/tree.ts";

test("writeJson/readJson roundtrips a config", async () => {
  const dir = await makeTempDir();
  try {
    const { configPath } = await createTree(dir);
    assert.equal(await exists(configPath), true);
    const config = await readConfig(configPath);
    assert.deepEqual(config, { name: "provenpin", version: 1, tags: ["a", "b"] });
  } finally {
    await removeTree(dir);
  }
});

test("copy duplicates the tree and move updates paths", async () => {
  const dir = await makeTempDir();
  try {
    const { sourceDir } = await createTree(dir);

    const copyDir = path.join(dir, "copy");
    await copyTree(sourceDir, copyDir);
    assert.equal(await exists(path.join(copyDir, "config.json")), true);
    assert.equal((await readConfig(path.join(copyDir, "config.json"))).name, "provenpin");

    const movedDir = path.join(dir, "moved");
    await moveTree(sourceDir, movedDir);
    assert.equal(await exists(sourceDir), false);
    assert.equal(await exists(path.join(movedDir, "config.json")), true);
    assert.equal((await readConfig(path.join(movedDir, "config.json"))).version, 1);
  } finally {
    await removeTree(dir);
  }
});

test("remove deletes the tree", async () => {
  const dir = await makeTempDir();
  const { sourceDir } = await createTree(dir);
  await removeTree(sourceDir);
  assert.equal(await exists(sourceDir), false);
  await removeTree(dir);
});

Connect to ProvenPin

Add the free MCP server so your agent can pull this recipe and others like it. Same setup as the docs.

terminal
claude mcp add --transport http provenpin https://mcp.provenpin.com/mcp

Any other MCP client: Streamable HTTP at https://mcp.provenpin.com/mcp. No API key, no signup.