From b011cc8a9abdc36e7aceba119c985e846868e1f0 Mon Sep 17 00:00:00 2001 From: Oyasuminasai <61616918+nfnfgo@users.noreply.github.com> Date: Sat, 13 Jul 2024 10:32:10 +0800 Subject: [PATCH 1/3] fix: Fix the issue that logger broke main process. --- src/utils/logger_main.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/utils/logger_main.ts b/src/utils/logger_main.ts index 3f422f7..ecc6726 100644 --- a/src/utils/logger_main.ts +++ b/src/utils/logger_main.ts @@ -28,14 +28,18 @@ export const LogPathHelper = { * Generate a writer function that used to write log into log file. */ export function generateMainProcessLogerWriter() { - var logFolderPath = LogPathHelper.getLogFolderPath(); - var logFilePath = LogPathHelper.getLogFilePath(); + let logFolderPath = LogPathHelper.getLogFolderPath(); + let logFilePath = LogPathHelper.getLogFilePath(); console.log(`[markdown-it] logFolderPath: ${logFolderPath}`); console.log(`[markdown-it] logFilePath: ${logFilePath}`); // clear former log file - rmSync(logFolderPath, { recursive: true }); + try { + rmSync(logFolderPath, { recursive: true }); + } catch (e) { + console.error('[markdown-it] Failed to remove previous log file'); + } // create dir if not exists try { @@ -43,7 +47,8 @@ export function generateMainProcessLogerWriter() { mkdirSync(logFolderPath, { recursive: true }); } } catch (err) { - console.error(err); + console.error('[markdown-it] Failed to create log directory'); + return undefined; } var stream = createWriteStream(logFilePath, { From 9ae76cd571380e87c182df0354fb4ebb5ba09fa8 Mon Sep 17 00:00:00 2001 From: Oyasuminasai <61616918+nfnfgo@users.noreply.github.com> Date: Sat, 13 Jul 2024 10:41:08 +0800 Subject: [PATCH 2/3] fix: Change log file position, currently in data folder. --- src/utils/logger_main.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/logger_main.ts b/src/utils/logger_main.ts index ecc6726..63ca4bb 100644 --- a/src/utils/logger_main.ts +++ b/src/utils/logger_main.ts @@ -7,7 +7,7 @@ declare const LiteLoader: LiteLoaderInterFace; export const LogPathHelper = { getLogFolderPath() { - return path.join(LiteLoader.plugins.markdown_it.path.plugin, 'log'); + return path.join(LiteLoader.plugins.markdown_it.path.data, 'log'); }, /** @@ -20,7 +20,7 @@ export const LogPathHelper = { // generate log file name if not received logFileName ??= (new Date().toISOString()).replaceAll(':', '-'); - return path.join(LiteLoader.plugins.markdown_it.path.plugin, 'log', `${logFileName}.log`); + return path.join(LogPathHelper.getLogFolderPath(), `${logFileName}.log`); } }; From 43080891833f718c52ccbb063eb17ce7dd25ee7c Mon Sep 17 00:00:00 2001 From: Oyasuminasai <61616918+nfnfgo@users.noreply.github.com> Date: Sat, 13 Jul 2024 10:41:17 +0800 Subject: [PATCH 3/3] 2.3.5 --- manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index e5dda1d..0d17cec 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "slug": "markdown_it", "icon": "./icon.png", "description": "为 QQNT 提供 Markdown 渲染", - "version": "2.3.4", + "version": "2.3.5", "authors": [ { "name": "d0j1a_1701", @@ -16,7 +16,7 @@ "repo": "d0j1a1701/LiteLoaderQQNT-Markdown", "branch": "v4", "release": { - "tag": "2.3.4", + "tag": "2.3.5", "file": "Release.zip" } },