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

Function runExecutor

apps/desktop/src/main/service.ts:65–87  ·  view source on GitHub ↗
(
  args: ReadonlyArray<string>,
  options: { readonly dataDir: string },
)

Source from the content-addressed store, hash-verified

63});
64
65const runExecutor = async (
66 args: ReadonlyArray<string>,
67 options: { readonly dataDir: string },
68): Promise<CommandResult> => {
69 const bin = bundledExecutorPath();
70 try {
71 const { stdout, stderr } = await execFileAsync(bin, [...args], {
72 encoding: "utf8",
73 env: await serviceEnv(options.dataDir),
74 });
75 return { code: 0, stdout, stderr };
76 } catch (error) {
77 const err = error as { code?: number | string; stdout?: string; stderr?: string };
78 if (typeof err.code === "string") {
79 throw new Error(`Failed to run \`${bin}\`: ${err.code}`);
80 }
81 return {
82 code: typeof err.code === "number" ? err.code : 1,
83 stdout: err.stdout ?? "",
84 stderr: err.stderr ?? "",
85 };
86 }
87};
88
89const statusValue = (stdout: string, key: "Registered" | "Running"): boolean =>
90 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