How do I delay the closing of Electron app to run script?


#1

I need to run a script and wait for its completion before I exit the app. The script is being run in PowerShell using node-powershell. I have tried the window.onbeforeunload function which works when I return false but returning false disables the close function. Is there a way to delay the unload for a few seconds while my script completes or another method?


#2

Scripts emit an ‘on close’ event

https://nodejs.org/api/child_process.html#child_process_event_close

Edit: Wrong module, but power shell node also has an exit event