Skip to content

Commit

Permalink
init : write repo and user config if they don't exist
Browse files Browse the repository at this point in the history
fixes #372

commit-id:66c8d4c5
  • Loading branch information
ejoffe committed Jan 12, 2024
1 parent 93956c4 commit 80ea6ee
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions config/config_parser/config_parser.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config_parser

import (
"errors"
"fmt"
"os"
"path"
Expand Down Expand Up @@ -49,6 +50,16 @@ func ParseConfig(gitcmd git.GitInterface) *config.Config {
rake.LoadSources(cfg.State,
rake.YamlFileWriter(InternalConfigFilePath()))

// init case : if yaml config files not found : create them
if _, err := os.Stat(RepoConfigFilePath(gitcmd)); errors.Is(err, os.ErrNotExist) {
rake.LoadSources(cfg.Repo,
rake.YamlFileWriter(RepoConfigFilePath(gitcmd)))
}

if _, err := os.Stat(UserConfigFilePath()); errors.Is(err, os.ErrNotExist) {
rake.LoadSources(cfg.User,
rake.YamlFileWriter(UserConfigFilePath()))
}
return cfg
}

Expand Down

0 comments on commit 80ea6ee

Please sign in to comment.