From 985ff4c57e0cd31b6ac2f2860f33f10318c6a0c4 Mon Sep 17 00:00:00 2001 From: Anton Nefjodov Date: Wed, 21 Dec 2022 15:25:13 +0200 Subject: [PATCH] - AbstractApp fix, logger fatal color changed --- package.json | 2 +- src/com/domwires/core/app/AbstractApp.ts | 12 +++++++++--- src/com/domwires/logger/ILogger.ts | 2 +- test/AppTest.ts | 17 +++++++++++++---- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index f126119..13399e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "domwires", - "version": "0.9.120", + "version": "0.9.125", "description": "Flexible and extensible MVC framework", "repository": { "type": "git", diff --git a/src/com/domwires/core/app/AbstractApp.ts b/src/com/domwires/core/app/AbstractApp.ts index 68e46b6..cbff1fe 100644 --- a/src/com/domwires/core/app/AbstractApp.ts +++ b/src/com/domwires/core/app/AbstractApp.ts @@ -30,11 +30,17 @@ export abstract class AbstractApp extends MessageDispatche } else { - fetch(configPath).then(() => + fetch(configPath).then((value) => { - if (configLoaded) configLoaded(true); - }).catch(() => + value.text().then(jsonStr => + { + this._appConfigJson = JSON.parse(jsonStr); + + if (configLoaded) configLoaded(true); + }); + }).catch(e => { + this.fatal(e); if (configLoaded) configLoaded(false); }); } diff --git a/src/com/domwires/logger/ILogger.ts b/src/com/domwires/logger/ILogger.ts index a13094e..24c92a5 100644 --- a/src/com/domwires/logger/ILogger.ts +++ b/src/com/domwires/logger/ILogger.ts @@ -89,7 +89,7 @@ export class Logger extends AbstractDisposable implements ILogger if (this.loglevel.level >= LogLevel.ERROR.level) { console.error(Logger.paintPrefix(this.caller(args), this.t) + " " + - Logger.paintArgs(Color.TP_ANSI_BG_CYAN, ...args)); + Logger.paintArgs(Color.TP_ANSI_FG_RED, ...args)); } return this; diff --git a/test/AppTest.ts b/test/AppTest.ts index e32b3fa..3285798 100644 --- a/test/AppTest.ts +++ b/test/AppTest.ts @@ -10,16 +10,25 @@ describe('AppTest', function (this: Suite) { } - it('testAppConfig', async () => + it('testAppConfig', (done) => { const f = new Factory(new Logger(LogLevel.VERBOSE)); const app = f.getInstance(MockApp); app.loadConfig(success => { - expect(success).true; - expect(app.appConfigJson.name).equals("Anton"); - expect(app.appConfigJson.age).equals(36); + try + { + expect(success).true; + expect(app.appConfigJson.name).equals("Anton"); + expect(app.appConfigJson.age).equals(36); + + done(); + } catch (e) + { + console.error(e); + throw e; + } }); }); }); \ No newline at end of file