Skip to content

Commit 56b59c9

Browse files
committed
feat: exit the command when closing the application
1 parent 8089ebc commit 56b59c9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

scripts/watch.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,23 @@ function watchMain(server) {
2727
VITE_DEV_SERVER_HOST: address.address,
2828
VITE_DEV_SERVER_PORT: address.port,
2929
})
30+
3031
/**
3132
* @type {import('vite').Plugin}
3233
*/
3334
const startElectron = {
3435
name: 'electron-main-watcher',
3536
writeBundle() {
3637
clearConsole()
37-
electronProcess && electronProcess.kill()
38+
39+
if (electronProcess) {
40+
electronProcess.removeAllListeners()
41+
electronProcess.kill()
42+
electronProcess = null
43+
}
44+
3845
electronProcess = spawn(electron, ['.'], { stdio: 'inherit', env })
46+
electronProcess.on('exit', process.exit)
3947
},
4048
}
4149

0 commit comments

Comments
 (0)