MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / execFileUtf8

Function execFileUtf8

packages/server/src/svc/exec.ts:21–53  ·  view source on GitHub ↗
(
  file: string,
  args: readonly string[],
  options: ExecOptions = {},
)

Source from the content-addressed store, hash-verified

19
20
21export function execFileUtf8(
22 file: string,
23 args: readonly string[],
24 options: ExecOptions = {},
25): Promise<ExecResult> {
26 return new Promise((resolve) => {
27 execFile(
28 file,
29 [...args],
30 {
31 encoding: 'utf8',
32 windowsHide: options.windowsHide === true,
33 ...(options.timeoutMs !== undefined ? { timeout: options.timeoutMs } : {}),
34 env: options.env ?? process.env,
35 },
36 (err, stdout, stderr) => {
37 if (err === null) {
38 resolve({ stdout, stderr, code: 0 });
39 return;
40 }
41
42
43 const code = typeof (err as { code?: unknown }).code === 'number' ? (err as { code: number }).code : -1;
44 const message = err instanceof Error ? err.message : JSON.stringify(err);
45 resolve({
46 stdout: typeof stdout === 'string' ? stdout : '',
47 stderr: typeof stderr === 'string' && stderr.length > 0 ? stderr : message,
48 code,
49 });
50 },
51 );
52 });
53}

Callers 4

systemd.tsFile · 0.90
schtasks.tsFile · 0.90
defaultTaskExistsFunction · 0.90
launchd.tsFile · 0.90

Calls 1

resolveFunction · 0.50

Tested by

no test coverage detected