I'm currently working on a script where I want to be able to read the messages coming from child processes spawned from ShellJS
NPM package, which uses NodeJS child_process
. Currently, I am able to read most of the logs with the stdout.on("data", (data) => {...})
callback, But for some of the logs I need, they don't come through on the data
event. I have tried a number of different event names, but nothing seems to pick them up. On the pic below, the messages I want but can't get through to my code are the ones with <i>
at the beginning. These are all coming from webpack
.
Anyone know how I could get these messages or find out what event they may be coming using?
This is my current code:
_setup(){
this._shell = shell.exec("npm start", {
async: true,
cwd: this._app.cwd,
silent: false
})
if(!this._shell.stdout){
console.error("failed")
return;
}
this._shell.stdout.on("data", (data) => this._onMessage(data))
}
_onMessage(data) {
console.log("STDOUT message received", data)
const found = data.match(/.*Loopback: http:\/\/localhost:(.*)\/.*/)
console.log("found", found)
this._onUpdate();
}
So it appears that webpack logs come through on stderr as i got them coming through using: