-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaths.go
More file actions
30 lines (27 loc) · 720 Bytes
/
paths.go
File metadata and controls
30 lines (27 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package main
import (
"os"
"path/filepath"
"runtime"
)
// vexBinDir returns the OS-appropriate directory for vex-managed binaries.
//
// - macOS: ~/.local/share/vex
// - Linux: $XDG_DATA_HOME/vex (defaults to ~/.local/share/vex)
func vexBinDir() string {
if runtime.GOOS == "linux" {
base := os.Getenv("XDG_DATA_HOME")
if base == "" {
home, _ := os.UserHomeDir()
base = filepath.Join(home, ".local", "share")
}
return filepath.Join(base, "vex")
}
// darwin and other unix
home, _ := os.UserHomeDir()
return filepath.Join(home, ".local", "share", "vex")
}
// ensureBinDir creates the vex bin directory if it doesn't exist.
func ensureBinDir() error {
return os.MkdirAll(vexBinDir(), 0755)
}