Skip to content

Commit

Permalink
fix: forgot to read config after initial config write
Browse files Browse the repository at this point in the history
  • Loading branch information
kahnwong committed Aug 10, 2024
1 parent 7dbede3 commit 93a1972
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ func init() {
if err != nil {
log.Fatal().Err(err).Msg("Error obtaining home directory")
}
err = os.MkdirAll(filepath.Join(homeDir, ".config", "wakatime-cli"), os.ModePerm)
err = os.MkdirAll(filepath.Join(homeDir, ".config", "waka"), os.ModePerm)
if err != nil {
log.Fatal().Err(err).Msg("Error creating config path")
}

//// write yaml
filename := filepath.Join(homeDir, ".config", "wakatime-cli", "config.yaml")
filename := filepath.Join(homeDir, ".config", "waka", "config.yaml")
file, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
log.Fatal().Err(err).Msg("Error creating config file")
Expand All @@ -81,6 +81,13 @@ func init() {
if err != nil {
log.Fatal().Err(err).Msg("Error writing config")
}

// read config to viper
err = viper.ReadInConfig()
if err != nil {
log.Fatal().Err(err).Msg("Error reading config after config initialization")
}

}

// rootCmd
Expand Down

0 comments on commit 93a1972

Please sign in to comment.