8000 resolve discussions · symfony-cli/symfony-cli@3f9f2f2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3f9f2f2

Browse files
committed
resolve discussions
1 parent 6cde8a1 commit 3f9f2f2

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

util/util.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ import (
2626
"runtime"
2727
)
2828

29+
const confDir = "symfony5"
30+
2931
func GetHomeDir() string {
3032
return getUserHomeDir()
3133
}
3234

3335
func getUserHomeDir() string {
34-
dir := "symfony5"
35-
dotDir := "." + dir
3636

3737
if InCloud() {
3838
u, err := user.Current()
3939
if err != nil {
40-
return filepath.Join(os.TempDir(), dir)
40+
return filepath.Join(os.TempDir(), confDir)
4141
}
42-
return filepath.Join(os.TempDir(), u.Username, dir)
42+
return filepath.Join(os.TempDir(), u.Username, confDir)
4343
}
4444

4545
home, err := os.UserHomeDir()
@@ -48,23 +48,22 @@ func getUserHomeDir() string {
4848
}
4949

5050
// use the old path if it exists already
51-
fallback := filepath.Join(home, dotDir)
52-
if _, err := os.Stat(fallback); !os.IsNotExist(err) {
53-
return fallback
51+
legacy := filepath.Join(home, "."+confDir)
52+
if _, err := os.Stat(legacy); !os.IsNotExist(err) {
53+
return legacy
5454
}
5555

5656
// macos only: if $HOME/.config exist, prefer that over 'Library/Application Support'
5757
if runtime.GOOS == "darwin" {
5858
dotconf := filepath.Join(home, ".config")
5959
if _, err := os.Stat(dotconf); !os.IsNotExist(err) {
60-
return filepath.Join(dotconf, dir)
60+
return filepath.Join(dotconf, confDir)
6161
}
6262
}
6363

64-
userCfg, err := os.UserConfigDir()
65-
if err != nil {
66-
return fallback
64+
if userCfg, err := os.UserConfigDir(); err == nil {
65+
return filepath.Join(userCfg, confDir)
6766
}
6867

69-
return filepath.Join(userCfg, dir)
68+
return legacy
7069
}

0 commit comments

Comments
 (0)
0