diff --git a/config.go b/config.go index 5f79fa7..97f38e0 100644 --- a/config.go +++ b/config.go @@ -56,6 +56,7 @@ func readConfigFile() (url, token string, err error) { } // SaveConfig persists the Forgejo URL and API token to the default config file. +// It creates the parent directory if it does not already exist. // // Usage: // @@ -65,6 +66,9 @@ func SaveConfig(url, token string) error { if err != nil { return err } + if err := coreio.Local.EnsureDir(filepath.Dir(path)); err != nil { + return core.E("SaveConfig", "forge: create config directory", err) + } payload, err := json.MarshalIndent(configFile{URL: url, Token: token}, "", " ") if err != nil { return core.E("SaveConfig", "forge: encode config file", err)