Skip to content

Commit

Permalink
fix: Modify parsing login for yaml config file
Browse files Browse the repository at this point in the history
In case blank lines only text
  • Loading branch information
Hsieh Chin Fan committed Sep 13, 2024
1 parent 387ea8e commit 34972b5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/mapclay.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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' {{{
Expand Down

0 comments on commit 34972b5

Please sign in to comment.