I'm trying to write a nodejs script to both spawn a watcher process and spawn another process to start my dev server but I need the watcher to finish building, start watching before the dev server is started. I have tried using timeouts, but difficult to gauge when build is complete.
var spawn = require('child_process').spawn
fileWatcher = spawn('cmd', [args'], { stdio: 'inherit' })
setTimeout(function() {
devServer = spawn('node', ['server/index.js'], { stdio: 'inherit' })
},20000)
Is there a way of knowing when either child process isn't outputting any data, at least then I'll know it's done/waiting for input.
If
{ stdio: 'inherit' }
is not required then you could use something like this: