close chokidar watcher before quit

This commit is contained in:
Labhansh Agrawal 2021-01-07 17:14:09 +05:30 committed by Benjamin Staneck
parent b6c2eb6478
commit 14a34d33dd

View file

@ -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) => {