runBuilds

tcmts.cli.run.runBuilds · #u3wnyzyf · term · runs on the server

uses tcmts.cli.main.execute, which uses tcmts.cli.help.usageError, which uses tcmts.cli.help.usageOf, which uses tcmts.cli.style.bold, which uses node:util

Runs tcm builds, without opening the codebase.

import { makeBuild, printBuilds } from "#codebase/tcmts/cli/builds";
import { Codebase } from "#codebase/tcmts/cli/codebase";
import { routeBuilds } from "#codebase/tcmts/cli/commands";
import { execute } from "#codebase/tcmts/cli/main";
import type { Started } from "#codebase/tcmts/cli/run";
import { dim } from "#codebase/tcmts/cli/style";
import { UsageError } from "#codebase/tcmts/cli/ui";
import { parse } from "@bomb.sh/router";

export function runBuilds({ cmd, rest, cwd, kept }: Started): number {
  // the builds kept don't need a codebase; what they were made from is said from this one's history, if there is one
  const r = execute(cmd, parse(routeBuilds(), { argv: rest }));
  if (r.route === "/make") {
    if (!kept)
      throw new UsageError(
        "no builds are kept here: TCM_BUILDS names the directory to keep them in (tcm's repository's dist/)",
      );
    const { build, made } = makeBuild(Codebase.find(cwd), kept, r.model.entry);
    console.log(
      `${made ? "made" : "kept already:"} ${build.name} ${dim(`(${build.bin})`)}: \`tcm --build ${build.name} <command>\` runs it`,
    );
    return 0;
  }
  let cb: Codebase | undefined;
  try {
    cb = Codebase.find(cwd);
  } catch {}
  printBuilds(kept, cb);
  return 0;
}

uses

used by