runTcm
uses node:child_process
Run tcm (this process's, as its command line runs it) with args in the codebase's directory root, as you would:
without the studio's own variables, or the codebase's or branch's, unless branch keeps the branch tcm dev serves
(TCM_BRANCH). What it said, colours taken out, and its exit code.
import { tcmEnv } from "#codebase/tcmts/studio"; import { execFile } from "node:child_process"; import { stripVTControlCharacters } from "node:util"; export function runTcm( root: string, args: string[], how: { branch?: boolean } = {}, ): Promise<{ code: number; text: string }> { const env: NodeJS.ProcessEnv = { ...tcmEnv(), NO_COLOR: "1" }; if (!how.branch) delete env.TCM_BRANCH; return new Promise((resolve) => execFile( process.execPath, [process.argv[1]!, ...args], { cwd: root, env, maxBuffer: 16 * 2 ** 20 }, (e, stdout, stderr) => resolve({ code: e ? (typeof e.code === "number" ? e.code : 1) : 0, text: stripVTControlCharacters(`${stdout}${stderr}`).trim(), }), ), ); }
uses
used by
- tcmts.studio.abortMerge
- tcmts.studio.addLib
- tcmts.studio.announceRelease
- tcmts.studio.checkLib
- tcmts.studio.editDefinition
- tcmts.studio.fixesOf
- tcmts.studio.makeBranch
- tcmts.studio.makeRelease
- tcmts.studio.migrateTable
- tcmts.studio.removeBranch
- tcmts.studio.removeDefinition
- tcmts.studio.removeLib
- tcmts.studio.renameDefinition
- tcmts.studio.renameInScratch
- tcmts.studio.resolveConflict
- tcmts.studio.switchBranch
- tcmts.studio.updateScratch
- tcmts.studio.upgradeLib
- tcmts.studio.upgradePackage