0

I'm running the Node JS child process spawn command to run some commands and am listening for some data from the commands that I run. Unfortunately, my script is exiting and I need it to remain running to monitor the progress of the terminals I'm opening automatically...

// command to run
const cmd = `ttab 'cd ${process.env.FORMS_FOLDER}application-${form} && dep deploy --tag="${release}" ${brand.stage}'`

// spawn a child process and
// run the command for deployment
const child = spawn(cmd, {
  shell: true
})

child.stdout.on('data', (data) => {
  console.log('STDOUT: ', data.toString()) // never running for some reason??
})

child.on('exit', function (code, signal) {
  console.log('child process exited with ' + `code ${code} and signal ${signal}`) // script is exiting?
})
Ryan H
  • 2,620
  • 4
  • 37
  • 109
  • Can you log what `child.stderr` outputs? Maybe your command fails to run – Tasos Sep 21 '20 at 08:32
  • The terminal opens up multiple terminal instances with the `ttab` package and runs the commands in them, the original terminal that initiated the commands just exits - anyway I can check the status of those other terminals? – Ryan H Sep 21 '20 at 08:35
  • Did you check this answer? https://stackoverflow.com/a/15286337/5605822 – Tasos Sep 21 '20 at 08:38

0 Answers0