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