setKeptInto

tcmts.studio.setKeptInto · #4ypqxpva · term · runs on the server

uses node:fs

Keep (or, with no name, forget) the name the file kept as written at abs goes back to.

import type { Codebase } from "#codebase/tcmts/cli/codebase";
import { keptInto, keptIntoFile } from "#codebase/tcmts/studio";
import fs from "node:fs";
import path from "node:path";

export function setKeptInto(cb: Codebase, abs: string, name: string | undefined): void {
  const all = keptInto(cb);
  if (name) all[abs] = name;
  else delete all[abs];
  fs.mkdirSync(path.dirname(keptIntoFile(cb)), { recursive: true });
  fs.writeFileSync(keptIntoFile(cb), `${JSON.stringify(all, null, 2)}\n`);
}

uses

used by