mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-06 12:47:13 +02:00
More Hot-Reload related changes
* Config.get(): Returns the latest config * Update code all over the place to use Config.get() vs Config.conf (which will be deprecated)
This commit is contained in:
parent
ca0149eaf0
commit
1fe46894d3
42 changed files with 320 additions and 273 deletions
|
@ -1,7 +1,7 @@
|
|||
/* jslint node: true */
|
||||
'use strict';
|
||||
|
||||
const Config = require('./config.js').config;
|
||||
const Config = require('./config.js').get;
|
||||
const ConfigCache = require('./config_cache.js');
|
||||
const Events = require('./events.js');
|
||||
|
||||
|
@ -15,7 +15,7 @@ exports.getFullConfig = getFullConfig;
|
|||
function getConfigPath(filePath) {
|
||||
// |filePath| is assumed to be in the config path if it's only a file name
|
||||
if('.' === paths.dirname(filePath)) {
|
||||
filePath = paths.join(Config.paths.config, filePath);
|
||||
filePath = paths.join(Config().paths.config, filePath);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
@ -24,19 +24,20 @@ function init(cb) {
|
|||
// pre-cache menu.hjson and prompt.hjson + establish events
|
||||
const changed = ( { fileName, fileRoot } ) => {
|
||||
const reCachedPath = paths.join(fileRoot, fileName);
|
||||
if(reCachedPath === getConfigPath(Config.general.menuFile)) {
|
||||
if(reCachedPath === getConfigPath(Config().general.menuFile)) {
|
||||
Events.emit(Events.getSystemEvents().MenusChanged);
|
||||
} else if(reCachedPath === getConfigPath(Config.general.promptFile)) {
|
||||
} else if(reCachedPath === getConfigPath(Config().general.promptFile)) {
|
||||
Events.emit(Events.getSystemEvents().PromptsChanged);
|
||||
}
|
||||
};
|
||||
|
||||
const config = Config();
|
||||
async.series(
|
||||
[
|
||||
function menu(callback) {
|
||||
return ConfigCache.getConfigWithOptions(
|
||||
{
|
||||
filePath : getConfigPath(Config.general.menuFile),
|
||||
filePath : getConfigPath(config.general.menuFile),
|
||||
callback : changed,
|
||||
},
|
||||
callback
|
||||
|
@ -45,7 +46,7 @@ function init(cb) {
|
|||
function prompt(callback) {
|
||||
return ConfigCache.getConfigWithOptions(
|
||||
{
|
||||
filePath : getConfigPath(Config.general.promptFile),
|
||||
filePath : getConfigPath(config.general.promptFile),
|
||||
callback : changed,
|
||||
},
|
||||
callback
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue