mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-12 05:38:04 +00:00
Dont unwrap json output by default
This commit is contained in:
parent
dfdbbbb24a
commit
33e35d10dd
@ -109,6 +109,21 @@ func TestReadUnwrapCmd(t *testing.T) {
|
||||
test.AssertResult(t, "'frog' # my favourite\n", result.Output)
|
||||
}
|
||||
|
||||
func TestReadUnwrapJsonByDefaultCmd(t *testing.T) {
|
||||
|
||||
content := `b: 'frog' # my favourite`
|
||||
filename := test.WriteTempYamlFile(content)
|
||||
defer test.RemoveTempYamlFile(filename)
|
||||
|
||||
cmd := getRootCommand()
|
||||
result := test.RunCmd(cmd, fmt.Sprintf("read %s b -j", filename))
|
||||
|
||||
if result.Error != nil {
|
||||
t.Error(result.Error)
|
||||
}
|
||||
test.AssertResult(t, "\"frog\"\n", result.Output)
|
||||
}
|
||||
|
||||
func TestCompareSameCmd(t *testing.T) {
|
||||
cmd := getRootCommand()
|
||||
result := test.RunCmd(cmd, "compare ../examples/data1.yaml ../examples/data1.yaml")
|
||||
|
@ -103,7 +103,7 @@ func transformNode(node *yaml.Node) *yaml.Node {
|
||||
|
||||
func printNode(node *yaml.Node, writer io.Writer) error {
|
||||
var encoder yqlib.Encoder
|
||||
if node.Kind == yaml.ScalarNode && unwrapScalar {
|
||||
if node.Kind == yaml.ScalarNode && unwrapScalar && !outputToJSON {
|
||||
return writeString(writer, node.Value+"\n")
|
||||
}
|
||||
if outputToJSON {
|
||||
|
Loading…
Reference in New Issue
Block a user