From b551e0c1b57aecf3f736c588fd1cfedeee161ced Mon Sep 17 00:00:00 2001 From: fyears <1142836+fyears@users.noreply.github.com> Date: Thu, 6 Jan 2022 18:38:18 +0800 Subject: [PATCH] fix config --- src/configPersist.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/configPersist.ts b/src/configPersist.ts index 21ca829..9810cd9 100644 --- a/src/configPersist.ts +++ b/src/configPersist.ts @@ -18,10 +18,14 @@ interface MessyConfigType { * this should accept the result after loadData(); */ export const messyConfigToNormal = ( - x: MessyConfigType | RemotelySavePluginSettings -): RemotelySavePluginSettings => { + x: MessyConfigType | RemotelySavePluginSettings | null | undefined +): RemotelySavePluginSettings | null | undefined => { log.debug("loading, original config on disk:"); log.debug(x); + if (x === null || x === undefined) { + log.debug("the messy config is null or undefined, skip"); + return x as any; + } if ("readme" in x && "d" in x) { // we should decode const y = JSON.parse( @@ -45,7 +49,13 @@ export const messyConfigToNormal = ( /** * this should accept the result of original config */ -export const normalConfigToMessy = (x: RemotelySavePluginSettings) => { +export const normalConfigToMessy = ( + x: RemotelySavePluginSettings | null | undefined +) => { + if (x === null || x === undefined) { + log.debug("the normal config is null or undefined, skip"); + return x; + } const y = { readme: DEFAULT_README, d: reverseString(