fix: can't save config if directory doesn't exists
This commit is contained in:
parent
cb8bb29bc0
commit
155672abe2
1 changed files with 8 additions and 1 deletions
|
|
@ -67,6 +67,13 @@ func getUserConfigDir() (string, error) {
|
|||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get user configuration path: %w", err)
|
||||
}
|
||||
filename := filepath.Join(userConfigPath, "forgejo-cli", "config.json")
|
||||
configDir := filepath.Join(userConfigPath, "forgejo-cli")
|
||||
if _, err := os.Stat(configDir); os.IsNotExist(err) {
|
||||
err = os.MkdirAll(configDir, 0700)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to create config dir: %w", err)
|
||||
}
|
||||
}
|
||||
filename := filepath.Join(configDir, "config.json")
|
||||
return filename, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue