fix config

This commit is contained in:
fyears 2022-01-06 18:38:18 +08:00
parent c65c0aa258
commit b551e0c1b5
1 changed files with 13 additions and 3 deletions

View File

@ -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(