feat: exit the command when closing the application

This commit is contained in:
lzdyes 2022-05-14 20:09:22 +08:00
parent 8089ebcb90
commit 56b59c9702
No known key found for this signature in database
GPG Key ID: 2FE62F8D86CEB3C5

View File

@ -27,6 +27,7 @@ function watchMain(server) {
VITE_DEV_SERVER_HOST: address.address,
VITE_DEV_SERVER_PORT: address.port,
})
/**
* @type {import('vite').Plugin}
*/
@ -34,8 +35,15 @@ function watchMain(server) {
name: 'electron-main-watcher',
writeBundle() {
clearConsole()
electronProcess && electronProcess.kill()
if (electronProcess) {
electronProcess.removeAllListeners()
electronProcess.kill()
electronProcess = null
}
electronProcess = spawn(electron, ['.'], { stdio: 'inherit', env })
electronProcess.on('exit', process.exit)
},
}