run

tcmts.loader.run · #ms5uestb · term · runs on the server

uses node:child_process

Run a definition: call it with args if it's a function, await the result, print it if not undefined.

import { nodeArgs, writeRunner } from "#codebase/tcmts/loader";
import type { DefSource, Layout } from "#codebase/tcmts/loader";
import { spawnSync } from "node:child_process";

export function run(hash: string, args: string[], src: DefSource, lay: Layout): number {
  const r = spawnSync(process.execPath, [...nodeArgs(lay), writeRunner(hash, src, lay), ...args], { stdio: "inherit" });
  return r.status ?? 1;
}

uses

used by