removeDefinition

tcmts.studio.removeDefinition · #rsjw6z7i · term · runs on the server

uses tcmts.studio.editableCodebase, which uses tcmts.share.servedCodebase, which uses process

Remove the name name, as tcm rm does (it's run, on the branch the studio serves): with force, even though named definitions use it (they keep working: they use it by hash). What it said.

import { HttpError } from "#codebase/tcmts/server";
import { editableCodebase, runTcm } from "#codebase/tcmts/studio";

export async function removeDefinition(name: string, force: boolean): Promise<string> {
  const cb = editableCodebase();
  const out = await runTcm(cb.lay.root, ["rm", name, ...(force ? ["--force"] : [])], {
    branch: true,
  });
  if (out.code !== 0)
    throw new HttpError(
      400,
      out.text.split("\n").slice(0, 8).join("\n") || `tcm rm ${name} failed`,
    );
  return out.text.split("\n")[0] ?? "";
}

uses

used by