MCPcopy
hub / github.com/openclaw/clawsweeper / runText

Function runText

src/command.ts:11–33  ·  view source on GitHub ↗
(
  command: string,
  args: string[],
  {
    cwd,
    env,
    maxBuffer = 64 * 1024 * 1024,
    stdio = ["ignore", "pipe", "pipe"],
    trim = "end",
  }: RunTextOptions = {},
)

Source from the content-addressed store, hash-verified

9};
10
11export function runText(
12 command: string,
13 args: string[],
14 {
15 cwd,
16 env,
17 maxBuffer = 64 * 1024 * 1024,
18 stdio = ["ignore", "pipe", "pipe"],
19 trim = "end",
20 }: RunTextOptions = {},
21): string {
22 const resolved = resolveCommand(command, args);
23 const text = execFileSync(resolved.command, resolved.args, {
24 cwd,
25 encoding: "utf8",
26 env: { ...process.env, GIT_OPTIONAL_LOCKS: "0", ...env },
27 maxBuffer,
28 stdio,
29 });
30 if (trim === "both") return text.trim();
31 if (trim === "end") return text.trimEnd();
32 return text;
33}
34
35function resolveCommand(command: string, args: string[]): { command: string; args: string[] } {
36 if (command === "gh" && process.env.GH_BIN) {

Callers 5

runFunction · 0.85
optionalGhJsonFunction · 0.85
runFunction · 0.85
runFunction · 0.85
runFunction · 0.85

Calls 1

resolveCommandFunction · 0.85

Tested by

no test coverage detected