Skip to content

Commit 6a5e2fb

Browse files
committed
fix(serve): process not exiting after killing electron
1 parent 7e3505b commit 6a5e2fb

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ module.exports = (api, options) => {
258258

259259
// Function to bundle main process and start Electron
260260
const startElectron = () => {
261+
queuedBuilds++
261262
if (bundleMainProcess) {
262263
// Build the main process
263264
const bundle = bundleMain({
@@ -333,8 +334,6 @@ module.exports = (api, options) => {
333334
const chokidar = require('chokidar')
334335
mainProcessWatch.forEach(file => {
335336
chokidar.watch(api.resolve(file)).on('all', () => {
336-
queuedBuilds++
337-
338337
if (args.debug) {
339338
// Rebuild main process
340339
startElectron()
@@ -345,10 +344,12 @@ module.exports = (api, options) => {
345344
return
346345
}
347346

348-
// Set auto restart flag
349-
childRestartOnExit = 1
350-
if (child) {
351-
// Start Electron if it hasn't been already launched
347+
// Chokidar calls this on initial launch,
348+
// so don't do anything if Electron hasn't been launched yet
349+
if (child || childRestartOnExit === 1) {
350+
// Set auto restart flag
351+
childRestartOnExit = 1
352+
// Start Electron
352353
startElectron()
353354
}
354355
})

0 commit comments

Comments
 (0)