Fix up some deprecated config refs

This commit is contained in:
Bryan Ashby 2020-06-07 21:21:31 -06:00
parent eb4f933285
commit dd2a6258d5
No known key found for this signature in database
GPG Key ID: B49EB437951D2542
5 changed files with 27 additions and 26 deletions

View File

@ -175,10 +175,11 @@ function initialize(cb) {
async.series(
[
function createMissingDirectories(callback) {
async.each(Object.keys(conf.config.paths), function entry(pathKey, next) {
mkdirs(conf.config.paths[pathKey], function dirCreated(err) {
const Config = conf.get();
async.each(Object.keys(Config.paths), function entry(pathKey, next) {
mkdirs(Config.paths[pathKey], function dirCreated(err) {
if(err) {
console.error('Could not create path: ' + conf.config.paths[pathKey] + ': ' + err.toString());
console.error('Could not create path: ' + Config.paths[pathKey] + ': ' + err.toString());
}
return next(err);
});

View File

@ -106,9 +106,7 @@ function mergeValidateAndFinalize(config, cb) {
return callback(null, mergedConfig);
},
function setIt(mergedConfig, callback) {
// :TODO: .config property is to be deprecated once conversions are done
exports.config = currentConfiguration = mergedConfig;
currentConfiguration = mergedConfig;
exports.get = () => currentConfiguration;
return callback(null);
}

View File

@ -2,7 +2,7 @@
'use strict';
// ENiGMA½
const conf = require('./config.js');
const conf = require('./config');
// deps
const sqlite3 = require('sqlite3');
@ -30,7 +30,8 @@ function getTransactionDatabase(db) {
}
function getDatabasePath(name) {
return paths.join(conf.config.paths.db, `${name}.sqlite3`);
const Config = conf.get();
return paths.join(Config.paths.db, `${name}.sqlite3`);
}
function getModDatabasePath(moduleInfo, suffix) {
@ -53,7 +54,8 @@ function getModDatabasePath(moduleInfo, suffix) {
(full.split('.').length > 1 && HOST_RE.test(full)),
'packageName must follow Reverse Domain Name Notation - https://en.wikipedia.org/wiki/Reverse_domain_name_notation');
return paths.join(conf.config.paths.modsDb, `${full}.sqlite3`);
const Config = conf.get();
return paths.join(Config.paths.modsDb, `${full}.sqlite3`);
}
function loadDatabaseForMod(modInfo, cb) {

View File

@ -2,7 +2,7 @@
'use strict';
// ENiGMA½
const conf = require('./config.js');
const Config = require('./config').get;
const logger = require('./logger.js');
const ServerModule = require('./server_module.js').ServerModule;
const clientConns = require('./client_connections.js');
@ -28,7 +28,7 @@ module.exports = class LoginServerModule extends ServerModule {
//
// Choose initial theme before we have user context
//
const preLoginTheme = _.get(conf.config, 'theme.preLogin');
const preLoginTheme = _.get(Config(), 'theme.preLogin');
if('*' === preLoginTheme) {
client.user.properties[UserProps.ThemeId] = theme.getRandomTheme() || '';
} else {

View File

@ -433,10 +433,10 @@ function getThemeArt(options, cb) {
const config = Config();
if(!options.themeId && _.has(options, [ 'client', 'user', 'properties', UserProps.ThemeId ])) {
options.themeId = options.client.user.properties[UserProps.ThemeId];
} else {
options.themeId = config.theme.default;
}
options.themeId = options.themeId || config.theme.default;
// :TODO: replace asAnsi stuff with something like retrieveAs = 'ansi' | 'pipe' | ...
// :TODO: Some of these options should only be set if not provided!
options.asAnsi = true; // always convert to ANSI