Fixes auto expansion of properties #1127

This commit is contained in:
Mike Farah 2022-03-01 11:29:11 +11:00
parent 2e731c310f
commit edbdb16ab7
3 changed files with 11 additions and 13 deletions

View File

@ -95,6 +95,7 @@ func (dec *propertiesDecoder) Decode(rootYamlNode *yaml.Node) error {
if err != nil { if err != nil {
return err return err
} }
properties.DisableExpansion = true
rootMap := &CandidateNode{ rootMap := &CandidateNode{
Node: &yaml.Node{ Node: &yaml.Node{

View File

@ -144,16 +144,3 @@ person.pets.0 = dog
person.food.0 = pizza person.food.0 = pizza
``` ```
## Empty doc
Given a sample.properties file of:
```properties
```
then
```bash
yq -p=props sample.properties
```
will output
```yaml
```

View File

@ -83,6 +83,13 @@ var propertyScenarios = []formatScenario{
expected: expectedDecodedYaml, expected: expectedDecodedYaml,
scenarioType: "decode", scenarioType: "decode",
}, },
{
description: "does not expand automatically",
skipDoc: true,
input: "mike = ${dontExpand} this",
expected: "mike: ${dontExpand} this\n",
scenarioType: "decode",
},
{ {
description: "Roundtrip", description: "Roundtrip",
input: expectedProperties, input: expectedProperties,
@ -176,6 +183,9 @@ func documentRoundTripPropertyScenario(w *bufio.Writer, s formatScenario) {
func documentPropertyScenario(t *testing.T, w *bufio.Writer, i interface{}) { func documentPropertyScenario(t *testing.T, w *bufio.Writer, i interface{}) {
s := i.(formatScenario) s := i.(formatScenario)
if s.skipDoc {
return
}
if s.scenarioType == "decode" { if s.scenarioType == "decode" {
documentDecodePropertyScenario(w, s) documentDecodePropertyScenario(w, s)
} else if s.scenarioType == "roundtrip" { } else if s.scenarioType == "roundtrip" {