networkedCodebase

tcmts.cli.test.e2e.contributions.networkedCodebase · #uq2m27xa · function · runs on the server

uses node:path

A codebase in root whose commands run alongside this process (onFakeNetwork's), so the fake network, in this process, answers the sign-ins and look-ups they make, theirs and the server's.

import type { onFakeNetwork } from "#codebase/tcmts/cli/test/e2e/releases";
import fs from "node:fs";
import path from "node:path";

export async function networkedCodebase(
  on: ReturnType<typeof onFakeNetwork>,
  root: string,
  name: string,
) {
  const dir = path.join(root, name);
  fs.mkdirSync(dir);
  const run = (...args: string[]) => on.run(dir, ...args);
  const tcm = (...args: string[]) => on.ok(dir, ...args);
  const write = (text: string) => fs.writeFileSync(path.join(dir, "scratch.ts"), text);
  await tcm("init");
  return { dir, run, tcm, write };
}

uses

used by