Skip to content

Commit 04f2049

Browse files
committed
Keep spawn options helper internal
1 parent 45b63b4 commit 04f2049

3 files changed

Lines changed: 23 additions & 25 deletions

File tree

‎packages/platform-node-shared/src/NodeChildProcessSpawner.ts‎

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
} from "effect/unstable/process/ChildProcessSpawner"
4141
import * as NodeChildProcess from "node:child_process"
4242
import { PassThrough } from "node:stream"
43+
import { buildSpawnOptions } from "./internal/nodeChildProcessSpawner.ts"
4344
import { handleErrnoException } from "./internal/utils.ts"
4445
import * as NodeSink from "./NodeSink.ts"
4546
import * as NodeStream from "./NodeStream.ts"
@@ -669,26 +670,6 @@ export const layer: Layer.Layer<
669670
// Internal Helpers
670671
// =============================================================================
671672

672-
/**
673-
* Builds the Node.js spawn options for a child process command.
674-
*
675-
* @category constructors
676-
* @since 4.0.0
677-
*/
678-
export const buildSpawnOptions = (
679-
options: ChildProcess.CommandOptions,
680-
base: Pick<NodeChildProcess.SpawnOptions, "cwd" | "env" | "stdio">,
681-
platform: NodeJS.Platform
682-
): NodeChildProcess.SpawnOptions => {
683-
const detached = options.detached ?? platform !== "win32"
684-
return {
685-
...base,
686-
detached,
687-
shell: options.shell,
688-
windowsHide: options.windowsHide ?? !detached
689-
}
690-
}
691-
692673
/**
693674
* Result of flattening a pipeline of commands.
694675
*
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type * as ChildProcess from "effect/unstable/process/ChildProcess"
2+
import type * as NodeChildProcess from "node:child_process"
3+
4+
export const buildSpawnOptions = (
5+
options: ChildProcess.CommandOptions,
6+
base: Pick<NodeChildProcess.SpawnOptions, "cwd" | "env" | "stdio">,
7+
platform: NodeJS.Platform
8+
): NodeChildProcess.SpawnOptions => {
9+
const detached = options.detached ?? platform !== "win32"
10+
return {
11+
...base,
12+
detached,
13+
shell: options.shell,
14+
windowsHide: options.windowsHide ?? !detached
15+
}
16+
}

‎packages/platform-node-shared/test/NodeChildProcessSpawner.test.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { buildSpawnOptions } from "@effect/platform-node-shared/internal/nodeChildProcessSpawner"
12
import * as NodeChildProcessSpawner from "@effect/platform-node-shared/NodeChildProcessSpawner"
23
import * as NodeFileSystem from "@effect/platform-node-shared/NodeFileSystem"
34
import * as NodePath from "@effect/platform-node-shared/NodePath"
@@ -23,19 +24,19 @@ describe("buildSpawnOptions", () => {
2324
const base = { stdio: "pipe" } as const
2425

2526
it("defaults to hiding non-detached Windows children", () => {
26-
assert.deepStrictEqual(NodeChildProcessSpawner.buildSpawnOptions({}, base, "win32"), {
27+
assert.deepStrictEqual(buildSpawnOptions({}, base, "win32"), {
2728
stdio: "pipe",
2829
detached: false,
2930
shell: undefined,
3031
windowsHide: true
3132
})
32-
assert.deepStrictEqual(NodeChildProcessSpawner.buildSpawnOptions({ detached: true }, base, "win32"), {
33+
assert.deepStrictEqual(buildSpawnOptions({ detached: true }, base, "win32"), {
3334
stdio: "pipe",
3435
detached: true,
3536
shell: undefined,
3637
windowsHide: false
3738
})
38-
assert.deepStrictEqual(NodeChildProcessSpawner.buildSpawnOptions({ detached: false }, base, "win32"), {
39+
assert.deepStrictEqual(buildSpawnOptions({ detached: false }, base, "win32"), {
3940
stdio: "pipe",
4041
detached: false,
4142
shell: undefined,
@@ -45,7 +46,7 @@ describe("buildSpawnOptions", () => {
4546

4647
it("allows windowsHide to be configured independently of detached", () => {
4748
assert.deepStrictEqual(
48-
NodeChildProcessSpawner.buildSpawnOptions({ detached: false, windowsHide: false }, base, "win32"),
49+
buildSpawnOptions({ detached: false, windowsHide: false }, base, "win32"),
4950
{
5051
stdio: "pipe",
5152
detached: false,
@@ -54,7 +55,7 @@ describe("buildSpawnOptions", () => {
5455
}
5556
)
5657
assert.deepStrictEqual(
57-
NodeChildProcessSpawner.buildSpawnOptions({ detached: true, windowsHide: true }, base, "win32"),
58+
buildSpawnOptions({ detached: true, windowsHide: true }, base, "win32"),
5859
{
5960
stdio: "pipe",
6061
detached: true,

0 commit comments

Comments
 (0)