Replace gaze with chokidar for config watcher (#1946)

* Replace gaze with chokidar for config watcher

* Pin deps
This commit is contained in:
Albin Ekblom 2017-08-13 00:23:48 +02:00 committed by Leo Lamprecht
parent d9dc415eff
commit be8e0cce29
3 changed files with 826 additions and 51 deletions

View file

@ -1,4 +1,4 @@
const gaze = require('gaze');
const chokidar = require('chokidar');
const notify = require('./notify');
const _import = require('./config/import');
const _openConfig = require('./config/open');
@ -10,20 +10,23 @@ const watchers = [];
// https://github.com/zeit/hyper/pull/1772
const watchCfg = process.platform === 'win32' ? {interval: 2000} : {};
let cfg = {};
let _watcher;
const _watch = function () {
gaze(cfgPath, watchCfg, function (err) {
if (err) {
throw err;
}
this.on('changed', () => {
cfg = _import();
notify('Configuration updated', 'Hyper configuration reloaded!');
watchers.forEach(fn => fn());
});
this.on('error', () => {
// Ignore file watching errors
});
if (_watcher) {
return _watcher;
}
_watcher = chokidar.watch(cfgPath, watchCfg);
_watcher.on('change', () => {
cfg = _import();
notify('Configuration updated', 'Hyper configuration reloaded!');
watchers.forEach(fn => fn());
});
_watcher.on('error', error => {
console.error('error watching config', error);
});
};

View file

@ -11,6 +11,7 @@
"repository": "zeit/hyper",
"xo": false,
"dependencies": {
"chokidar": "1.7.0",
"color": "0.11.3",
"convert-css-color-name-to-hex": "0.1.1",
"default-shell": "1.0.1",
@ -18,7 +19,6 @@
"electron-is-dev": "0.1.1",
"electron-squirrel-startup": "1.0.0",
"file-uri-to-path": "0.0.2",
"gaze": "1.1.2",
"git-describe": "3.0.2",
"mkdirp": "0.5.1",
"ms": "0.7.1",

File diff suppressed because it is too large Load diff