-
Notifications
You must be signed in to change notification settings - Fork 11
/
setting.go
53 lines (42 loc) · 840 Bytes
/
setting.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"io/ioutil"
"os"
"path/filepath"
)
var setting *Setting
func init() {
pwd, err := os.Getwd()
check(err)
setting = &Setting{
ProjectDir: pwd,
ConfigFile: filepath.Join(pwd, "Nut.toml"),
ConfigLockFile: filepath.Join(pwd, "Nut.lock"),
}
}
type Setting struct {
ProjectDir string
ConfigFile string
ConfigLockFile string
goPath string
manifest *Manifest
}
func (s *Setting) WorkDir() string {
if s.goPath == "" {
temp, err := ioutil.TempDir("", "nut")
check(err)
s.goPath = temp
}
return s.goPath
}
func (s *Setting) VendorDir() string {
return filepath.Join(setting.ProjectDir, "vendor", "_nuts")
}
func (s *Setting) Manifest() *Manifest {
if s.manifest == nil {
var err error
s.manifest, err = loadManifest()
check(err)
}
return s.manifest
}