Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Commit

Permalink
fix: only write yml when origin format is yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
boypt committed Aug 16, 2021
1 parent 246f012 commit 06cf167
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion engine/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"path/filepath"
"reflect"
"strings"
"time"

"github.com/spf13/viper"
Expand Down Expand Up @@ -222,7 +223,10 @@ func (c *Config) SyncViper(nc Config) {

func (c *Config) WriteDefault() error {
cf := viper.ConfigFileUsed()
return c.WriteYaml(cf)
if strings.HasSuffix(cf, ".yml") || strings.HasSuffix(cf, ".yaml") {
return c.WriteYaml(cf)
}
return viper.WriteConfig()
}

func (c *Config) WriteYaml(cf string) error {
Expand Down

0 comments on commit 06cf167

Please sign in to comment.