Open History to see the last commit
1diff --git a/dist/NodeChildProcessSpawner.d.ts b/dist/NodeChildProcessSpawner.d.ts
2--- a/dist/NodeChildProcessSpawner.d.ts
3+++ b/dist/NodeChildProcessSpawner.d.ts
4@@ -35,6 +35,8 @@
5 import * as Path from "effect/Path";
6 import * as ChildProcess from "effect/process/ChildProcess";
7 import { ChildProcessSpawner } from "effect/process/ChildProcessSpawner";
8+import type * as NodeChildProcess from "node:child_process";
9+import type { Readable, Writable } from "node:stream";
10 /**
11 * Layer that provides the `NodeChildProcessSpawner` implementation.
12 *
13@@ -44,6 +46,25 @@
14 */
15 export declare const layer: Layer.Layer<ChildProcessSpawner, never, FileSystem.FileSystem | Path.Path>;
16 /**
17+ * The part of `ChildProcess` the spawner uses: `spawn`, `error` and `exit`
18+ * events, the pid, stdio streams, `kill`, `ref` and `unref`.
19+ */
20+export interface SpawnedChildProcess extends NodeJS.EventEmitter {
21+ readonly pid?: number | undefined;
22+ readonly stdin: Writable | null;
23+ readonly stdout: Readable | null;
24+ readonly stderr: Readable | null;
25+ readonly stdio: ReadonlyArray<Readable | Writable | null | undefined>;
26+ kill(signal?: NodeJS.Signals | number): boolean;
27+ ref(): void;
28+ unref(): void;
29+}
30+/**
31+ * `layer` with a replacement for `child_process.spawn` that returns a
32+ * `ChildProcess`-compatible object.
33+ */
34+export declare const layerWithSpawn: (spawnProcess: (command: string, args: ReadonlyArray<string>, options: NodeChildProcess.SpawnOptions) => SpawnedChildProcess) => Layer.Layer<ChildProcessSpawner, never, FileSystem.FileSystem | Path.Path>;
35+/**
36 * Result of flattening a pipeline of commands.
37 *
38 * @stability unstable
39diff --git a/dist/NodeChildProcessSpawner.js b/dist/NodeChildProcessSpawner.js
40--- a/dist/NodeChildProcessSpawner.js
41+++ b/dist/NodeChildProcessSpawner.js
42@@ -62,7 +62,7 @@
43 windowsHide: true
44 }, onExit);
45 };
46-const make = /*#__PURE__*/Effect.gen(function* () {
47+const makeWithSpawn = spawnProcess => Effect.gen(function* () {
48 const fs = yield* FileSystem.FileSystem;
49 const path = yield* Path.Path;
50 const resolveWorkingDirectory = Effect.fnUntraced(function* (options) {
51@@ -278,7 +278,7 @@
52 };
53 const spawn = (command, spawnOptions) => Effect.callback(resume => {
54 const deferred = Deferred.makeUnsafe();
55- const handle = NodeChildProcess.spawn(command.command, command.args, spawnOptions);
56+ const handle = spawnProcess(command.command, command.args, spawnOptions);
57 handle.on("error", error => {
58 resume(Effect.fail(toPlatformError("spawn", error, command)));
59 });
60@@ -570,7 +570,8 @@
61 * @category layers
62 * @since 4.0.0
63 */
64-export const layer = /*#__PURE__*/Layer.effect(ChildProcessSpawner, make);
65+export const layer = /*#__PURE__*/Layer.effect(ChildProcessSpawner, /*#__PURE__*/makeWithSpawn(NodeChildProcess.spawn));
66+export const layerWithSpawn = spawnProcess => Layer.effect(ChildProcessSpawner, makeWithSpawn(spawnProcess));
67 /**
68 * Flattens a `Command` into an array of `StandardCommand`s along with pipe
69 * options for each connection.