fix: check the value of encoder before encoding
This commit is contained in:
parent
7d74a20fe8
commit
3928222636
1 changed files with 7 additions and 1 deletions
|
@ -146,7 +146,13 @@ func runTag(ctx context.Context, opts TagOptions, gopts GlobalOptions, args []st
|
|||
}
|
||||
|
||||
if gopts.JSON {
|
||||
json.NewEncoder(gopts.stdout).Encode(changedSnapshots)
|
||||
encoder := json.NewEncoder(gopts.stdout)
|
||||
if encoder != nil {
|
||||
err := encoder.Encode(changedSnapshots)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for _, changedSnapshot := range changedSnapshots {
|
||||
Printf("%v -> %v\n", changedSnapshot.Original, changedSnapshot.New)
|
||||
|
|
Loading…
Add table
Reference in a new issue