fix(forge): create config directory before saving
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
4b27f1072a
commit
6236446883
1 changed files with 4 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue