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

View file

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

File diff suppressed because it is too large Load diff