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

Function runExecutor

apps/desktop/src/main/service.ts:78–102  ·  view source on GitHub ↗
(
  args: ReadonlyArray<string>,
  options: { readonly dataDir: string; readonly captureUserPath?: boolean },
)

Source from the content-addressed store, hash-verified

76};
77
78const runExecutor = async (
79 args: ReadonlyArray<string>,
80 options: { readonly dataDir: string; readonly captureUserPath?: boolean },
81): Promise<CommandResult> => {
82 const bin = bundledExecutorPath();
83 try {
84 const { stdout, stderr } = await execFileAsync(bin, [...args], {
85 encoding: "utf8",
86 env: await serviceEnv(options.dataDir, {
87 captureUserPath: options.captureUserPath ?? true,
88 }),
89 });
90 return { code: 0, stdout, stderr };
91 } catch (error) {
92 const err = error as { code?: number | string; stdout?: string; stderr?: string };
93 if (typeof err.code === "string") {
94 throw new Error(`Failed to run \`${bin}\`: ${err.code}`);
95 }
96 return {
97 code: typeof err.code === "number" ? err.code : 1,
98 stdout: err.stdout ?? "",
99 stderr: err.stderr ?? "",
100 };
101 }
102};
103
104const statusValue = (stdout: string, key: "Registered" | "Running"): boolean =>
105 new RegExp(`^${key}:\\s+yes(?:\\s|$)`, "im").test(stdout);

Callers 4

supervisedServiceStatusFunction · 0.85
installSupervisedServiceFunction · 0.85
restartSupervisedServiceFunction · 0.85

Calls 2

bundledExecutorPathFunction · 0.85
serviceEnvFunction · 0.85

Tested by

no test coverage detected