-
Notifications
You must be signed in to change notification settings - Fork 3
/
env.go
34 lines (27 loc) · 595 Bytes
/
env.go
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
31
32
33
34
package project
import (
"os"
"os/user"
"path/filepath"
"github.com/pkg/errors"
)
func InstallDir() (string, error) {
homeDir, found := os.LookupEnv("OYA_HOME")
if !found {
user, err := user.Current()
if err != nil {
return "", err
}
if len(user.HomeDir) == 0 {
return "", errors.Errorf("Could not detect user home directory")
}
homeDir = user.HomeDir
}
return filepath.Join(homeDir, ".oya", "packs"), nil
}
func LookupOyaScope() (string, bool) {
return os.LookupEnv("OYA_SCOPE")
}
func SetOyaScope(scope string) error {
return os.Setenv("OYA_SCOPE", scope)
}