From 6d862d246ab39b66333251a4ca6beb95d47ca89a Mon Sep 17 00:00:00 2001 From: pauhull <22707808+pauhull@users.noreply.github.com> Date: Thu, 4 Jan 2024 13:52:15 +0100 Subject: [PATCH] Fix error if cli.toml does not exist --- internal/state/state.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/state/state.go b/internal/state/state.go index 9ea01c9b..9fde1837 100644 --- a/internal/state/state.go +++ b/internal/state/state.go @@ -101,9 +101,14 @@ 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) @@ -111,7 +116,6 @@ func readConfig(path string) (*Config, error) { return nil, err } - cfg := &Config{Path: path} if err = UnmarshalConfig(cfg, data); err != nil { return nil, err }