Skip to content

Commit

Permalink
Assets download shouldn't use CWD if there is no config file (#107)
Browse files Browse the repository at this point in the history
* When a user runs assets download they may not have created a
.foyle/config.yaml file yet

* As a result the ConfigDir will be the empty string and assets will be
put into the local directory
* To solve this if the ConfigFile is empty we return the default config
directory.

Fix #103
  • Loading branch information
jlewi authored May 14, 2024
1 parent ca7e8a7 commit b517998
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,13 @@ func (c *Config) GetLogLevel() string {

// GetConfigDir returns the configuration directory
func (c *Config) GetConfigDir() string {
return filepath.Dir(viper.ConfigFileUsed())
configFile := viper.ConfigFileUsed()
if configFile != "" {
return filepath.Dir(configFile)
}

// Since there is no config file we will use the default config directory.
return binHome()
}

// IsValid validates the configuration and returns any errors.
Expand Down

0 comments on commit b517998

Please sign in to comment.