From 34972b5d70d8173a9e03310662836af6d37b4ee6 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Fri, 13 Sep 2024 19:52:54 +0800 Subject: [PATCH] fix: Modify parsing login for yaml config file In case blank lines only text --- src/mapclay.mjs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/mapclay.mjs b/src/mapclay.mjs index acbd248..fa6025f 100644 --- a/src/mapclay.mjs +++ b/src/mapclay.mjs @@ -30,16 +30,18 @@ const parseConfigsFromYaml = (configText) => { configText, (result) => { if (typeof result === 'object' && !Array.isArray(result)) { - configList.push(result) - } else if (typeof result === 'string') { + configList.push(result ?? {}) + } else { if (configList.length > 0) { - configList.at(-1).eval = result + configList.at(-1).eval = result.toString() } } } ) - return configList.length > 0 ? configList : [{}] + if (configList.length == 0) throw Error('Not a valid config file') + + return configList } // }}} // Get config from other file by 'apply' {{{