setUp

tcmts.cli.test.e2e.watch.setUp · #qwrdya25 · term · runs on the server

uses node:fs

A new codebase, and a way to run tcm in it (failing the test if it fails, except for check).

import { tcmIn, tempDir } from "#codebase/tcmts/cli/test/e2e/harness";
import fs from "node:fs";
import path from "node:path";

export function setUp() {
  const dir = tempDir("watch");
  const tcm = (...args: string[]): string => {
    const r = tcmIn(dir, ...args);
    if (r.status !== 0 && args[0] !== "check") throw new Error(`tcm ${args.join(" ")} exited ${r.status}:\n${r.out}`);
    return r.out;
  };
  const scratch = (file: string, text: string) => fs.writeFileSync(path.join(dir, file), text);
  tcm("init");
  return { dir, tcm, scratch };
}

uses

used by