repository

tcmts.dev.repository · #c7nwfqyg · term · runs on the server

uses node:path

tcm's repository: up from here, the directory with scripts/codebase.sh (what gets the codebase, and where it, its known-good tcm and its builds are kept).

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

export function repository(): string {
  for (let d = process.cwd(); ; d = path.dirname(d)) {
    if (fs.existsSync(path.join(d, "scripts", "codebase.sh"))) return d;
    if (path.dirname(d) === d) throw new Error(`${process.cwd()} isn't in tcm's repository`);
  }
}

used by