Skip to content

Commit d4b02dc

Browse files
authored
Support >= 3 arguments in Spawn.stdio (#19358)
1 parent 26e296a commit d4b02dc

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

packages/bun-types/bun.d.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6433,7 +6433,8 @@ declare module "bun" {
64336433
* @default ["ignore", "pipe", "inherit"] for `spawn`
64346434
* ["ignore", "pipe", "pipe"] for `spawnSync`
64356435
*/
6436-
stdio?: [In, Out, Err];
6436+
stdio?: [In, Out, Err, ...Readable[]];
6437+
64376438
/**
64386439
* The file descriptor for the standard input. It may be:
64396440
*
@@ -6734,6 +6735,11 @@ declare module "bun" {
67346735
readonly stdout: SpawnOptions.ReadableToIO<Out>;
67356736
readonly stderr: SpawnOptions.ReadableToIO<Err>;
67366737

6738+
/**
6739+
* Access extra file descriptors passed to the `stdio` option in the options object.
6740+
*/
6741+
readonly stdio: [null, null, null, ...number[]];
6742+
67376743
/**
67386744
* This returns the same value as {@link Subprocess.stdout}
67396745
*
@@ -6750,6 +6756,7 @@ declare module "bun" {
67506756
* ```
67516757
*/
67526758
readonly pid: number;
6759+
67536760
/**
67546761
* The exit code of the process
67556762
*

test/integration/bun-types/fixture/spawn.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,21 @@ function depromise<T>(_promise: Promise<T>): T {
6363
console.log(text); // "const input = "hello world".repeat(400); ..."
6464
}
6565

66+
{
67+
const proc = Bun.spawn(["cat"], {
68+
stdio: ["pipe", "pipe", "pipe", Bun.file("build.zip")],
69+
});
70+
71+
tsd.expectType(proc.stdio[0]).is<null>();
72+
tsd.expectType(proc.stdio[1]).is<null>();
73+
tsd.expectType(proc.stdio[2]).is<null>();
74+
tsd.expectType(proc.stdio[3]).is<number | undefined>();
75+
76+
tsd.expectType(proc.stdin).is<FileSink>();
77+
tsd.expectType(proc.stdout).is<ReadableStream<Uint8Array>>();
78+
tsd.expectType(proc.stderr).is<ReadableStream<Uint8Array>>();
79+
}
80+
6681
{
6782
const proc = Bun.spawn(["cat"], {
6883
stdin: "pipe", // return a FileSink for writing

0 commit comments

Comments
 (0)