(
args: ReadonlyArray<string>,
options: { readonly dataDir: string; readonly captureUserPath?: boolean },
)
| 76 | }; |
| 77 | |
| 78 | const 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 | |
| 104 | const statusValue = (stdout: string, key: "Registered" | "Running"): boolean => |
| 105 | new RegExp(`^${key}:\\s+yes(?:\\s|$)`, "im").test(stdout); |
no test coverage detected