mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 12:25:47 +02:00
Return an error if document is not a dictionary
This commit is contained in:
parent
90084d115e
commit
221433522d
2 changed files with 15 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
package yaml_utils
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
|
@ -24,6 +25,10 @@ func UpdateYamlValue(yamlBytes []byte, path []string, value string) ([]byte, err
|
|||
|
||||
body := node.Content[0]
|
||||
|
||||
if body.Kind != yaml.MappingNode {
|
||||
return yamlBytes, errors.New("yaml document is not a dictionary")
|
||||
}
|
||||
|
||||
updateYamlNode(body, path, value)
|
||||
|
||||
// Convert the updated YAML node back to YAML bytes.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue