Skip to content

Commit

Permalink
Merge pull request #339 from kamaln7/issue/334
Browse files Browse the repository at this point in the history
Check legacy config file paths only if applicable to the current environment
  • Loading branch information
kamaln7 authored Aug 24, 2018
2 parents 016b85f + 3534121 commit 3b753db
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions commands/doit.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,24 @@ func findConfig() (string, error) {
return cfgFile, nil
}

legacyConfigPath := filepath.Join(homeDir(), ".doctlcfg")
if _, err := os.Stat(legacyConfigPath); err == nil {
msg := fmt.Sprintf("Configuration detected at %q. Please move .doctlcfg to %s",
legacyConfigPath, configPath())
warn(msg)
if homeDir() != "" {
legacyConfigPath := filepath.Join(homeDir(), ".doctlcfg")
if _, err := os.Stat(legacyConfigPath); err == nil {
msg := fmt.Sprintf("Configuration detected at %q. Please move .doctlcfg to %s",
legacyConfigPath, configPath())
warn(msg)
}
}

legacyXDGPath := filepath.Join(os.Getenv("XDG_CONFIG_HOME"), "config.yaml")
if _, err := os.Stat(legacyXDGPath); err == nil {
msg := fmt.Sprintf("Configuration detected at %q. Please move config.yaml to %s",
legacyXDGPath, configPath())
warn(msg)
if os.Getenv("XDG_CONFIG_HOME") != "" {
legacyXDGPath := filepath.Join(os.Getenv("XDG_CONFIG_HOME"), "config.yaml")
if _, err := os.Stat(legacyXDGPath); err == nil {
msg := fmt.Sprintf("Configuration detected at %q. Please move config.yaml to %s",
legacyXDGPath, configPath())
warn(msg)
}
}

ch := configHome()
if err := os.MkdirAll(ch, 0755); err != nil {
return "", err
Expand Down

0 comments on commit 3b753db

Please sign in to comment.