(
command: string,
args: string[],
{
cwd,
env,
maxBuffer = 64 * 1024 * 1024,
stdio = ["ignore", "pipe", "pipe"],
trim = "end",
}: RunTextOptions = {},
)
| 9 | }; |
| 10 | |
| 11 | export 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 | |
| 35 | function resolveCommand(command: string, args: string[]): { command: string; args: string[] } { |
| 36 | if (command === "gh" && process.env.GH_BIN) { |
no test coverage detected