runTcm
uses node:child_process
Run tcm in cwd and collect what it prints (without colour).
import { tcmCommand } from "#codebase/tcmts/vscode/extension"; import { spawn } from "node:child_process"; export function runTcm(args: string[], cwd: string | undefined): Promise<{ code: number | null; out: string }> { const [cmd, ...pre] = tcmCommand(); return new Promise((resolve) => { const p = spawn(cmd!, [...pre, ...args], { cwd, env: { ...process.env, NO_COLOR: "1", FORCE_COLOR: "0" } }); let out = ""; p.stdout.on("data", (d: Buffer) => (out += d)); p.stderr.on("data", (d: Buffer) => (out += d)); p.on("error", (e) => resolve({ code: 1, out: e.message })); p.on("exit", (code) => resolve({ code, out })); }); }