mirror of
https://github.com/mikefarah/yq.git
synced 2025-02-05 18:55:49 +00:00
Fixing merge
This commit is contained in:
parent
20fdc250d3
commit
2356ea0942
10
go.sum
10
go.sum
@ -57,13 +57,13 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
|
|||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
github.com/yuin/gopher-lua v1.1.0 h1:BojcDhfyDWgU2f2TOzYK/g5p2gxMrku8oupLDqlnSqE=
|
github.com/yuin/gopher-lua v1.1.0 h1:BojcDhfyDWgU2f2TOzYK/g5p2gxMrku8oupLDqlnSqE=
|
||||||
github.com/yuin/gopher-lua v1.1.0/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
|
github.com/yuin/gopher-lua v1.1.0/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
|
||||||
golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck=
|
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
|
||||||
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
|
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
||||||
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
|
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
||||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||||
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk=
|
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk=
|
||||||
|
@ -306,22 +306,25 @@ func (le *luaEncoder) encodeAny(writer io.Writer, node *CandidateNode) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (le *luaEncoder) Encode(writer io.Writer, node *CandidateNode) error {
|
func (le *luaEncoder) encodeTopLevel(writer io.Writer, node *CandidateNode) error {
|
||||||
if !le.globals && node.Parent == nil {
|
err := writeString(writer, le.docPrefix)
|
||||||
err := writeString(writer, le.docPrefix)
|
if err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err := le.encodeAny(writer, node); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
err = le.encodeAny(writer, node)
|
||||||
if !le.globals && node.Parent == nil {
|
if err != nil {
|
||||||
err := writeString(writer, le.docSuffix)
|
return err
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return nil
|
return writeString(writer, le.docSuffix)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (le *luaEncoder) Encode(writer io.Writer, node *CandidateNode) error {
|
||||||
|
|
||||||
|
if le.globals {
|
||||||
|
if node.Kind != MappingNode {
|
||||||
|
return fmt.Errorf("--lua-global requires a top level MappingNode")
|
||||||
|
}
|
||||||
|
return le.encodeMap(writer, node, true)
|
||||||
|
}
|
||||||
|
return le.encodeTopLevel(writer, node)
|
||||||
}
|
}
|
||||||
|
@ -11,47 +11,47 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var luaScenarios = []formatScenario{
|
var luaScenarios = []formatScenario{
|
||||||
// {
|
{
|
||||||
// description: "Basic input example",
|
description: "Basic input example",
|
||||||
// input: `return {
|
input: `return {
|
||||||
// ["country"] = "Australia"; -- this place
|
["country"] = "Australia"; -- this place
|
||||||
// ["cities"] = {
|
["cities"] = {
|
||||||
// "Sydney",
|
"Sydney",
|
||||||
// "Melbourne",
|
"Melbourne",
|
||||||
// "Brisbane",
|
"Brisbane",
|
||||||
// "Perth",
|
"Perth",
|
||||||
// };
|
};
|
||||||
// };
|
};
|
||||||
// `,
|
`,
|
||||||
// expected: `country: Australia
|
expected: `country: Australia
|
||||||
// cities:
|
cities:
|
||||||
// - Sydney
|
- Sydney
|
||||||
// - Melbourne
|
- Melbourne
|
||||||
// - Brisbane
|
- Brisbane
|
||||||
// - Perth
|
- Perth
|
||||||
// `,
|
`,
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// description: "Basic output example",
|
description: "Basic output example",
|
||||||
// scenarioType: "encode",
|
scenarioType: "encode",
|
||||||
// input: `---
|
input: `---
|
||||||
// country: Australia # this place
|
country: Australia # this place
|
||||||
// cities:
|
cities:
|
||||||
// - Sydney
|
- Sydney
|
||||||
// - Melbourne
|
- Melbourne
|
||||||
// - Brisbane
|
- Brisbane
|
||||||
// - Perth`,
|
- Perth`,
|
||||||
// expected: `return {
|
expected: `return {
|
||||||
// ["country"] = "Australia"; -- this place
|
["country"] = "Australia"; -- this place
|
||||||
// ["cities"] = {
|
["cities"] = {
|
||||||
// "Sydney",
|
"Sydney",
|
||||||
// "Melbourne",
|
"Melbourne",
|
||||||
// "Brisbane",
|
"Brisbane",
|
||||||
// "Perth",
|
"Perth",
|
||||||
// };
|
};
|
||||||
// };
|
};
|
||||||
// `,
|
`,
|
||||||
// },
|
},
|
||||||
{
|
{
|
||||||
description: "Basic roundtrip",
|
description: "Basic roundtrip",
|
||||||
skipDoc: true,
|
skipDoc: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user