1import * as Effect from "effect/Effect";
2import * as Stream from "effect/Stream";
3import type { ChildProcess } from "effect/process";
4
5export const exec = Effect.fn("exec")(function* (
6 command: ChildProcess.Command,
7) {
8 const handle = yield* command;
9 const [exitCode, stdout, stderr] = yield* Effect.all(
10 [
11 handle.exitCode,
12 Stream.mkString(Stream.decodeText(handle.stdout)),
13 Stream.mkString(Stream.decodeText(handle.stderr)),
14 ],
15 { concurrency: 3 },
16 );
17 return { exitCode, stdout, stderr };
18});