Skip to content

Commit

Permalink
Fixes auto expansion of properties #1127
Browse files Browse the repository at this point in the history
  • Loading branch information
mikefarah committed Mar 1, 2022
1 parent 2e731c3 commit edbdb16
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
1 change: 1 addition & 0 deletions pkg/yqlib/decoder_properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func (dec *propertiesDecoder) Decode(rootYamlNode *yaml.Node) error {
if err != nil {
return err
}
properties.DisableExpansion = true

rootMap := &CandidateNode{
Node: &yaml.Node{
Expand Down
13 changes: 0 additions & 13 deletions pkg/yqlib/doc/usage/properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,3 @@ person.pets.0 = dog
person.food.0 = pizza
```

## Empty doc
Given a sample.properties file of:
```properties

```
then
```bash
yq -p=props sample.properties
```
will output
```yaml
```

10 changes: 10 additions & 0 deletions pkg/yqlib/properties_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ var propertyScenarios = []formatScenario{
expected: expectedDecodedYaml,
scenarioType: "decode",
},
{
description: "does not expand automatically",
skipDoc: true,
input: "mike = ${dontExpand} this",
expected: "mike: ${dontExpand} this\n",
scenarioType: "decode",
},
{
description: "Roundtrip",
input: expectedProperties,
Expand Down Expand Up @@ -176,6 +183,9 @@ func documentRoundTripPropertyScenario(w *bufio.Writer, s formatScenario) {

func documentPropertyScenario(t *testing.T, w *bufio.Writer, i interface{}) {
s := i.(formatScenario)
if s.skipDoc {
return
}
if s.scenarioType == "decode" {
documentDecodePropertyScenario(w, s)
} else if s.scenarioType == "roundtrip" {
Expand Down

0 comments on commit edbdb16

Please sign in to comment.