In node.js I'm making call a script with exec from child_process.
When in the closed state I want to check if there was any error so I can return it however I can't seem to access error in the second function on().
Could someone kindly explain how I can pass it along.
exec('myScript.sh',
(error: any, stdout: any, stderr: any) => { }).on('close', () => {
console.log(error)
})
Thanks.