I have a node script to modify content of docker compose file (yaml file). I used yaml lib to parse from file:
const fs = require('fs')
const yaml = require('yaml')
const compose = yaml.parseDocument(fs.readFileSync(file, 'utf-8'), {merge: true})
... do something to modify content...
fs.writeFileSync(file, yaml.stringify(compose, {
nullStr: '',
simpleKeys: true,
lineWidth: 0
}))
after I write the updated content back to the file, there is no problem except it added new blank line after each null value (attached file)
I don’t know the reason why it do it (maybe the variable with null value is the reason). it’s default behaviour? How I can avoid it?