mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-05 17:36:59 +08:00
Fixed for most cases, except strip comments
This commit is contained in:
@@ -128,9 +128,14 @@ func (p *resultsPrinter) PrintResults(matchingNodes *list.List, leadingContent s
|
||||
}
|
||||
|
||||
if !printedLead {
|
||||
// we want to print this after the seperator logic
|
||||
if err := p.writeString(bufferedWriter, leadingContent); err != nil {
|
||||
return err
|
||||
// dont print leading comments and seperator if:
|
||||
// - we are print json; or
|
||||
// - we are printing an unwrapped scalar node
|
||||
if !p.outputToJSON && (mappedDoc.Node.Kind != yaml.ScalarNode || !p.unwrapScalar) {
|
||||
// we want to print this after the seperator logic
|
||||
if err := p.writeString(bufferedWriter, leadingContent); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
printedLead = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user