fix: omit nulls

This commit is contained in:
orion 2023-11-28 14:27:34 -06:00
parent 00fb682314
commit dd513b1aac
Signed by: orion
GPG Key ID: 6D4165AE4C928719

View File

@ -13,6 +13,15 @@ export function objToHash(valueToYAMLImpl, fst, snd, obj) {
}
export function toYAMLImpl(a) {
// noCompatMode does not support YAML 1.1
return yaml.dump(a, { noCompatMode: true })
const replacer = (_, v) => {
if (typeof v === 'object') {
Object.keys(v).forEach(k => {
if (v[k] === null) {
delete v[k]
}
})
}
}
return yaml.dump(a, { noCompatMode: true, replacer })
}