| 258 | } |
| 259 | |
| 260 | private maybeSetupIPC(child: ChildProcess) { |
| 261 | if (!this.ipc) { |
| 262 | return []; |
| 263 | } |
| 264 | |
| 265 | return [ |
| 266 | pipeTo( |
| 267 | Rx.fromEvent(child, 'message').pipe( |
| 268 | Rx.map((event) => { |
| 269 | const [message, handle] = event as [object, SendHandle | undefined]; |
| 270 | return { message, handle }; |
| 271 | }), |
| 272 | ), |
| 273 | this.messages.incoming, |
| 274 | ), |
| 275 | this.messages.outgoing.subscribe((message) => { |
| 276 | if (!child.send) { |
| 277 | return message.onSent(new Error('Command does not have an IPC channel')); |
| 278 | } |
| 279 | |
| 280 | child.send(message.message, message.handle, message.options, (error) => { |
| 281 | message.onSent(error); |
| 282 | }); |
| 283 | }), |
| 284 | ]; |
| 285 | } |
| 286 | |
| 287 | /** |
| 288 | * Sends a message to the underlying process once it starts. |