I've found some questions about writing to child_process
standard input, such as Nodejs Child Process: write to stdin from an already initialised process, however, I'm wondering if it is possible to recognize when a process spawned using Node's child_process
attempts to read from its standard input and take action on that (perhaps according to what it has written to its standard output up until then).
I see that the stdio streams are implemented using Stream in Node. Stream has an event called data
which is for when it is being written into, however, I see no event for detecting the stream is being read from.
Is the way to go here to subclass Stream
and override its read
method with custom implementation or is there a simpler way?