MCPcopy
hub / github.com/Swatinem/rust-cache / getCmdOutput

Function getCmdOutput

src/utils.ts:18–47  ·  view source on GitHub ↗
(
  cmdFormat: string,
  cmd: string,
  options: exec.ExecOptions = {},
)

Source from the content-addressed store, hash-verified

16}
17
18export async function getCmdOutput(
19 cmdFormat: string,
20 cmd: string,
21 options: exec.ExecOptions = {},
22): Promise<string> {
23 cmd = cmdFormat.replace("{0}", cmd);
24 let stdout = "";
25 let stderr = "";
26 try {
27 await exec.exec(cmd, [], {
28 silent: true,
29 listeners: {
30 stdout(data) {
31 stdout += data.toString();
32 },
33 stderr(data) {
34 stderr += data.toString();
35 },
36 },
37 ...options,
38 });
39 } catch (e) {
40 (e as any).commandFailed = {
41 command: cmd,
42 stderr,
43 };
44 throw e;
45 }
46 return stdout;
47}
48
49export interface GhCache {
50 isFeatureAvailable: typeof ghCache.isFeatureAvailable;

Callers 2

getPackagesMethod · 0.90
getRustVersionsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected