You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
path=filepath.Join(home, ".config", subFolder) // issue #33- putting into a subfolder to avoid clutter
33
-
subpath:=filepath.Join(home, ".config")
34
-
if_, err:=os.Stat(subpath); os.IsNotExist(err) {
35
-
os.Mkdir(subpath, 0700)
31
+
xdg, exists:=os.LookupEnv("XDG_CONFIG_HOME") // per comment in PR #71- using this env var if present
32
+
if!exists||xdg=="" {
33
+
// if not present, set sane defaults- APPDATA\twitch-cli for Windows, .config/twitch-cli for OSX/Linux
34
+
ifruntime.GOOS=="WINDOWS" {
35
+
path=filepath.Join("$APPDATA", subFolder)
36
+
} else {
37
+
path=filepath.Join(home, ".config", subFolder)
36
38
}
39
+
} else {
40
+
// if it does exist, then just use it and combine with the subfolder; example is: $HOME/.config/twitch-cli
41
+
path=filepath.Join(xdg, subFolder)
37
42
}
38
43
44
+
// if the full path doesn't exist, make all the folders to get there
39
45
if_, err:=os.Stat(path); os.IsNotExist(err) {
40
-
os.Mkdir(path, 0700)
46
+
err:=os.MkdirAll(path, os.ModePerm)
47
+
iferr!=nil {
48
+
return"", err
49
+
}
50
+
}
51
+
println(path)
52
+
53
+
// if the user ends up in this state, provide some basic diagnostic info
54
+
ifpath=="" {
55
+
triageMessage:=fmt.Sprintf("Invalid path generated; Please file a bugreport here: https://github.com/twitchdev/twitch-cli/issues/new\nInclude this in the report:\n-----\nOS: %v\nArchitecture: %v\nVersion: %v\n-----", runtime.GOOS, runtime.GOARCH, GetVersion())
0 commit comments