mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-13 22:38:04 +00:00
Handle scalars in property files
This commit is contained in:
parent
ac5346b138
commit
1b0a62d08d
@ -63,6 +63,11 @@ func (pe *propertiesEncoder) PrintLeadingContent(writer io.Writer, content strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (pe *propertiesEncoder) Encode(writer io.Writer, node *yaml.Node) error {
|
func (pe *propertiesEncoder) Encode(writer io.Writer, node *yaml.Node) error {
|
||||||
|
|
||||||
|
if node.Kind == yaml.ScalarNode {
|
||||||
|
return writeString(writer, node.Value+"\n")
|
||||||
|
}
|
||||||
|
|
||||||
mapKeysToStrings(node)
|
mapKeysToStrings(node)
|
||||||
p := properties.NewProperties()
|
p := properties.NewProperties()
|
||||||
err := pe.doEncode(p, node, "", nil)
|
err := pe.doEncode(p, node, "", nil)
|
||||||
|
@ -162,6 +162,14 @@ var propertyScenarios = []formatScenario{
|
|||||||
expected: "mike: ${dontExpand} this\n",
|
expected: "mike: ${dontExpand} this\n",
|
||||||
scenarioType: "decode",
|
scenarioType: "decode",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
description: "print scalar",
|
||||||
|
skipDoc: true,
|
||||||
|
input: "mike = cat",
|
||||||
|
expression: ".mike",
|
||||||
|
expected: "cat\n",
|
||||||
|
scenarioType: "roundtrip",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
description: "Roundtrip",
|
description: "Roundtrip",
|
||||||
input: expectedPropertiesUnwrapped,
|
input: expectedPropertiesUnwrapped,
|
||||||
|
Loading…
Reference in New Issue
Block a user