We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 71056f6 commit 8cfb004Copy full SHA for 8cfb004
internal/pkg/profile/types.go
@@ -1,7 +1,7 @@
1
package profile
2
3
import (
4
- "errors"
+ "os"
5
"path"
6
7
"github.com/spf13/viper"
@@ -35,10 +35,11 @@ func (p *Profile) Config() *Config {
35
v := viper.New()
36
v.SetConfigFile(path.Join(p.Directory, "config.json"))
37
38
- err := v.ReadInConfig()
39
- if err != nil && !errors.As(err, &viper.ConfigFileNotFoundError{}) {
40
- // For some reason viper doesnt implement Is() for ConfigFileNotFoundError
41
- panic(err) //todo
+ // Read the config file if it exists
+ if _, err := os.Stat(v.ConfigFileUsed()); err == nil {
+ if err := v.ReadInConfig(); err != nil {
+ panic(err) //todo this should proceed with default config and log an error
42
+ }
43
}
44
45
var config Config
0 commit comments