Skip to content

Commit

Permalink
fix: tree-kill doesn't work
Browse files Browse the repository at this point in the history
  • Loading branch information
caoxiemeihao committed Nov 6, 2023
1 parent 5e6c36d commit 234be07
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,20 @@ startup.hookProcessExit = false
startup.exit = async () => {
if (process.electronApp) {
process.electronApp.removeAllListeners()
try {
const { default: treeKill } = await import('tree-kill')
treeKill(process.electronApp.pid!)
} catch (e) {
process.electronApp.kill()
}

import('tree-kill')
.then(m => m.default(process.electronApp.pid!))
.catch(e => {
if (e.code === 'ERR_MODULE_NOT_FOUND') {
console.log(
'[vite-plugin-electron]',
'install tree-kill to exit all associated processes, place run "npm i tree-kill".',
)
} else {
console.error(e)
}
})

process.electronApp.kill() // `tree-kill` doesn't work locally on my Mac(2023-11-06) 🤔
}
}

0 comments on commit 234be07

Please sign in to comment.