Skip to content

Commit

Permalink
fix: if config already exists, return it
Browse files Browse the repository at this point in the history
  • Loading branch information
sammcj committed Nov 25, 2024
1 parent 0183bf5 commit 925bf97
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ func LoadConfig() (Config, error) {
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
// Config file not found; create it
if err := CreateDefaultConfig(); err != nil {
// if the file already exists - return it, otherwise throw an error
if _, err := os.Stat(getConfigPath()); err == nil {
return LoadConfig()
}
return Config{}, fmt.Errorf("failed to create default config: %w", err)
}
} else {
Expand Down

0 comments on commit 925bf97

Please sign in to comment.