MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / opCliExec

Function opCliExec

packages/plugins/onepassword/src/sdk/op-cli.ts:48–77  ·  view source on GitHub ↗
({
  args,
  env,
  timeoutMs,
  signal,
}: OpCliInvocation)

Source from the content-addressed store, hash-verified

46 * CLI's human-readable diagnostics, so a non-zero exit reports stderr when
47 * present (falling back to the spawn error, e.g. `spawn op ENOENT`). */
48export const opCliExec = ({
49 args,
50 env,
51 timeoutMs,
52 signal,
53}: OpCliInvocation): Promise<OpCliResult> =>
54 new Promise((resolve) => {
55 execFile(
56 "op",
57 args,
58 {
59 env: env as NodeJS.ProcessEnv,
60 timeout: timeoutMs,
61 signal,
62 maxBuffer: 16 * 1024 * 1024,
63 },
64 (error, stdout, stderr) => {
65 if (error === null) {
66 resolve({ ok: true, stdout });
67 return;
68 }
69 const stderrText = stderr.trim();
70 resolve({
71 ok: false,
72 timedOut: isExecFileError(error) && error.killed === true,
73 message: stderrText.length > 0 ? stderrText : describeSpawnError(error),
74 });
75 },
76 );
77 });

Callers 1

runFunction · 0.90

Calls 3

isExecFileErrorFunction · 0.85
describeSpawnErrorFunction · 0.85
resolveFunction · 0.50

Tested by

no test coverage detected