Skip to content

Commit

Permalink
Fix error if cli.toml does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
phm07 committed Jan 4, 2024
1 parent 428d700 commit 6d862d2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions internal/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,21 @@ func (c *state) readEnv() {
}

func readConfig(path string) (*Config, error) {
cfg := &Config{Path: path}

_, err := os.Stat(path)
if err != nil && !os.IsNotExist(err) {
return nil, err
if err != nil {
if os.IsNotExist(err) {
err = nil
}
return cfg, err
}

data, err := os.ReadFile(path)
if err != nil {
return nil, err
}

cfg := &Config{Path: path}
if err = UnmarshalConfig(cfg, data); err != nil {
return nil, err
}
Expand Down

0 comments on commit 6d862d2

Please sign in to comment.