Мелкие поправки

This commit is contained in:
Book Pauk
2019-12-23 20:57:44 +07:00
parent 0500a8178d
commit 1ed058a553
2 changed files with 4 additions and 3 deletions

View File

@@ -41,9 +41,9 @@ class ConfigManager {
process.env.NODE_ENV = this.branch;
this.branchConfigFile = __dirname + `/${this.branch}.js`;
await fs.access(this.branchConfigFile);
this._config = require(this.branchConfigFile);
await fs.ensureDir(this._config.dataDir);
this._userConfigFile = `${this._config.dataDir}/config.json`;
this.inited = true;
@@ -83,6 +83,7 @@ class ConfigManager {
async save() {
if (!this.inited)
throw new Error('not inited');
const dataToSave = _.pick(this._config, propsToSave);
await fs.writeFile(this.userConfigFile, JSON.stringify(dataToSave, null, 4));
}

View File

@@ -18,7 +18,7 @@ async function init() {
const log = appLogger.log;
//dirs
log(`${config.name} v${config.version}`);
log(`${config.name} v${config.version}, Node.js ${process.version}`);
log('Initializing');
await fs.ensureDir(config.dataDir);
@@ -40,7 +40,7 @@ async function init() {
await connManager.init(config);
}
async function main() {
async function main() {
const log = new (require('./core/AppLogger'))().log;//singleton
const config = new (require('./config'))().config;//singleton