diff --git a/cmd/commands_test.go b/cmd/commands_test.go index 266fb2c6..271eb52c 100644 --- a/cmd/commands_test.go +++ b/cmd/commands_test.go @@ -1872,14 +1872,16 @@ c: test.AssertResult(t, os.FileMode(int(0666)), info.Mode()) } -func TestMergeAllowEmptyCmd(t *testing.T) { +func TestMergeAllowEmptyTargetCmd(t *testing.T) { cmd := getRootCommand() - result := test.RunCmd(cmd, "merge --allow-empty ../examples/data1.yaml ../examples/empty.yaml") + result := test.RunCmd(cmd, "merge ../examples/empty.yaml ../examples/data1.yaml") if result.Error != nil { t.Error(result.Error) } expectedOutput := `a: simple # just the best -b: [1, 2] +b: +- 1 +- 2 c: test: 1 ` diff --git a/cmd/constant.go b/cmd/constant.go index 4c1c340e..7d5d590e 100644 --- a/cmd/constant.go +++ b/cmd/constant.go @@ -15,7 +15,6 @@ var defaultValue = "" var indent = 2 var overwriteFlag = false var autoCreateFlag = true -var allowEmptyFlag = false var appendFlag = false var verbose = false var version = false diff --git a/cmd/merge.go b/cmd/merge.go index 0d9905ae..645eb30d 100644 --- a/cmd/merge.go +++ b/cmd/merge.go @@ -1,8 +1,6 @@ package cmd import ( - "strings" - "github.com/mikefarah/yq/v3/pkg/yqlib" errors "github.com/pkg/errors" "github.com/spf13/cobra" @@ -34,7 +32,6 @@ If append flag is set then existing arrays will be merged with the arrays from e cmdMerge.PersistentFlags().BoolVarP(&overwriteFlag, "overwrite", "x", false, "update the yaml file by overwriting existing values") cmdMerge.PersistentFlags().BoolVarP(&autoCreateFlag, "autocreate", "c", true, "automatically create any missing entries") cmdMerge.PersistentFlags().BoolVarP(&appendFlag, "append", "a", false, "update the yaml file by appending array values") - cmdMerge.PersistentFlags().BoolVarP(&allowEmptyFlag, "allow-empty", "e", false, "allow empty yaml files") cmdMerge.PersistentFlags().StringVarP(&docIndex, "doc", "d", "0", "process document index number (0 based, * for all documents)") return cmdMerge } @@ -52,7 +49,7 @@ func mergeProperties(cmd *cobra.Command, args []string) error { for _, fileToMerge := range filesToMerge { matchingNodes, errorProcessingFile := readYamlFile(fileToMerge, "**", false, 0) - if errorProcessingFile != nil && (!allowEmptyFlag || !strings.HasPrefix(errorProcessingFile.Error(), "Could not process document index")) { + if errorProcessingFile != nil { return errorProcessingFile } for _, matchingNode := range matchingNodes {