From 14a34d33dd6428dba3616753f2c80045a383d3ac Mon Sep 17 00:00:00 2001 From: Labhansh Agrawal Date: Thu, 7 Jan 2021 17:14:09 +0530 Subject: [PATCH] close chokidar watcher before quit --- app/config.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/config.ts b/app/config.ts index 5aca99f9..564b96ae 100644 --- a/app/config.ts +++ b/app/config.ts @@ -6,6 +6,7 @@ import win from './config/windows'; import {cfgPath, cfgDir} from './config/paths'; import {getColorMap} from './utils/colors'; import {parsedConfig, configOptions} from '../lib/config'; +import {app} from 'electron'; const watchers: Function[] = []; let cfg: parsedConfig = {} as any; @@ -54,6 +55,15 @@ const _watch = () => { _watcher.on('error', (error) => { console.error('error watching config', error); }); + + app.on('before-quit', (e) => { + if (Object.keys(_watcher.getWatched()).length > 0) { + e.preventDefault(); + _watcher.close().then(() => { + app.quit(); + }); + } + }); }; export const subscribe = (fn: Function) => {