( command: string, args: ReadonlyArray<string>, cwd: string, env: NodeJS.ProcessEnv = process.env, )
| 22 | } |
| 23 | |
| 24 | const runCommand = async ( |
| 25 | command: string, |
| 26 | args: ReadonlyArray<string>, |
| 27 | cwd: string, |
| 28 | env: NodeJS.ProcessEnv = process.env, |
| 29 | ): Promise<CommandResult> => { |
| 30 | const child = spawn(command, [...args], { |
| 31 | cwd, |
| 32 | env, |
| 33 | stdio: ["ignore", "pipe", "pipe"], |
| 34 | }); |
| 35 | |
| 36 | let stdout = ""; |
| 37 | let stderr = ""; |
| 38 | |
| 39 | child.stdout.setEncoding("utf8"); |
| 40 | child.stdout.on("data", (chunk) => { |
| 41 | stdout += chunk; |
| 42 | }); |
| 43 | |
| 44 | child.stderr.setEncoding("utf8"); |
| 45 | child.stderr.on("data", (chunk) => { |
| 46 | stderr += chunk; |
| 47 | }); |
| 48 | |
| 49 | const exitCode = await new Promise<number>((resolveExitCode, reject) => { |
| 50 | child.once("error", reject); |
| 51 | child.once("close", (code) => { |
| 52 | resolveExitCode(code ?? -1); |
| 53 | }); |
| 54 | }); |
| 55 | |
| 56 | return { exitCode, stdout, stderr }; |
| 57 | }; |
| 58 | |
| 59 | const listen = async (server: ReturnType<typeof createServer>): Promise<number> => |
| 60 | Effect.runPromise( |
no outgoing calls
no test coverage detected