Description
Version of yq: v4.34.2
Operating system: Ubuntu Linux
Installed via: Don't remember, probably snap
Input Yaml
data1.yml:
---
b: banana
data2.md:
---
b: botato
---
not valid
yaml: code
Command
yq eval '.' data1.yml
# OK
yq eval-all '.' data1.yml data1.yml
# OK
yq --front-matter extract eval '.' data2.md
# OK
yq --front-matter extract eval-all '.' data2.md data2.md
# Error!
Actual behavior
yq --front-matter extract eval-all '.' data2.md data2.md
# Error: bad file 'data2.md': yaml: line 5: mapping values are not allowed in this context
Expected behavior
yq --front-matter extract eval-all '.' data2.md data2.md
# ---
# b: botato
# ---
# b: botato
Additional context
I would like a simple way to collect the metadata from a bunch of Markdown files into one array of objects. I've been extracting them into individual temporary yml
files using yq
and joining them afterwards, but now I want to skip the middle step and collect it all directly using eval-all
.
After some trial and a lot of error, it seems as if it's always the second file in the arguments where parsing fails, as if yq
doesn't know it's only concerned with the --front-matter
.
Another workaround for me could be, since the fields happen to always be the same in my case, something like
head -q -n 5 location/of/files/*.md | yq ea '. as $i ireduce ([]; . + $i)'
but that feels rather hacky. I would much rather that yq
handle the metadata from start to finish.