* Switch to sane over gaze for file watching: Gaze was not triggering on file additions

* Remove watching of config files for now -- doesn't work anyway. Will revisit later.
This commit is contained in:
Bryan Ashby 2017-10-02 21:06:53 -06:00
parent d5334270c4
commit 067bb9e884
4 changed files with 43 additions and 24 deletions

View file

@ -6,7 +6,6 @@ var Log = require('./logger.js').log;
var paths = require('path');
var fs = require('graceful-fs');
var Gaze = require('gaze').Gaze;
var events = require('events');
var util = require('util');
var assert = require('assert');
@ -18,7 +17,7 @@ function ConfigCache() {
var self = this;
this.cache = {}; // filePath -> HJSON
this.gaze = new Gaze();
//this.gaze = new Gaze();
this.reCacheConfigFromFile = function(filePath, cb) {
fs.readFile(filePath, { encoding : 'utf-8' }, function fileRead(err, data) {
@ -32,7 +31,7 @@ function ConfigCache() {
});
};
/*
this.gaze.on('error', function gazeErr(err) {
});
@ -50,6 +49,7 @@ function ConfigCache() {
}
});
});
*/
}
@ -58,13 +58,13 @@ util.inherits(ConfigCache, events.EventEmitter);
ConfigCache.prototype.getConfigWithOptions = function(options, cb) {
assert(_.isString(options.filePath));
var self = this;
// var self = this;
var isCached = (options.filePath in this.cache);
if(options.forceReCache || !isCached) {
this.reCacheConfigFromFile(options.filePath, function fileCached(err, config) {
if(!err && !isCached) {
self.gaze.add(options.filePath);
//self.gaze.add(options.filePath);
}
cb(err, config, true);
});
@ -82,4 +82,4 @@ ConfigCache.prototype.getModConfig = function(fileName, cb) {
this.getConfig(paths.join(Config.paths.mods, fileName), cb);
};
module.exports = exports = new ConfigCache();
module.exports = exports = new ConfigCache();