how to return when child process is complete in node js 1

how to return when child process is complete in node js

var child = require('child_process').exec('python celulas.py')
child.stdout.pipe(process.stdout)
child.on('exit', function() {
  process.exit()
})

Here is what the above code is Doing:
1. We’re requiring the child_process module, which is a core module.
2. We’re using the exec method to run the Python script.
3. We’re piping the output of the Python script to the output of the Node script.
4. We’re listening for the exit event on the child process.
5. We’re exiting the Node script when the child process exits.

Similar Posts