Skip to content

Commit 1025b3f

Browse files
committed
Add way to get child process stderr pipe
1 parent 9662709 commit 1025b3f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/client/stdio.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChildProcess, spawn } from "node:child_process";
1+
import { ChildProcess, IOType, spawn } from "node:child_process";
22
import process from "node:process";
33
import { ReadBuffer, serializeMessage } from "../shared/stdio.js";
44
import { JSONRPCMessage } from "../types.js";
@@ -28,7 +28,7 @@ export type StdioServerParameters = {
2828
*
2929
* The default is "inherit", meaning messages to stderr will be printed to the parent process's stderr.
3030
*/
31-
stderr?: "inherit" | "ignore" | Stream;
31+
stderr?: IOType | Stream | number;
3232
};
3333

3434
/**
@@ -123,7 +123,7 @@ export class StdioClientTransport implements Transport {
123123
// (i.e. via `electron-forge start`) vs a production environment
124124
// (i.e. YourApp.exe).
125125
detached: process.platform === "win32" && isElectron(),
126-
}
126+
},
127127
);
128128

129129
this._process.on("error", (error) => {
@@ -161,6 +161,15 @@ export class StdioClientTransport implements Transport {
161161
});
162162
}
163163

164+
/**
165+
* The stderr stream of the child process, if `StdioServerParameters.stderr` was set to "pipe" or "overlapped".
166+
*
167+
* This is only available after the process has been started.
168+
*/
169+
get stderr(): Stream | null {
170+
return this._process?.stderr ?? null;
171+
}
172+
164173
private processReadBuffer() {
165174
while (true) {
166175
try {

0 commit comments

Comments
 (0)