buildBin

tcmts.cli.builds.buildBin · #hqpakmky · term · runs on the server

uses node:path

A build's tcm.js: its tcm-ts install's, or another package's there with a tcm command (what tcm builds make installs from a codebase whose package of that command has another name).

import fs from "node:fs";
import path from "node:path";

export function buildBin(dir: string): string | undefined {
  const modules = path.join(dir, "node_modules");
  const tcmTs = path.join(modules, "tcm-ts", "bin", "tcm.js");
  if (fs.existsSync(tcmTs)) return tcmTs;
  let names: string[];
  try {
    names = fs.readdirSync(modules).sort();
  } catch {
    return undefined;
  }
  for (const n of names) {
    const bin = path.join(modules, n, "bin", "tcm.js");
    if (fs.existsSync(bin)) return bin;
  }
  return undefined;
}

used by