-
Notifications
You must be signed in to change notification settings - Fork 3
/
project_funcs.go
56 lines (38 loc) · 1.1 KB
/
project_funcs.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
54
55
56
// Package samb has server-assembly's (SAMB) struct types.
package samb
import (
"os"
)
// ProcessImports handles finding
// and merging imports defined by project.
func (p *Project) ProcessImports() {
if p.Server.Require != nil {
p.Require = append(p.Require, p.Server.Require...)
}
if p.Server.Routes.Route != nil {
p.Routes.Route = append(p.Routes.Route, p.Server.Routes.Route...)
}
wd, err := os.Getwd()
if err != nil {
panic(err)
}
for _, i := range p.Require {
os.Chdir(wd)
file, err := Load(i)
if err != nil {
panic(err)
}
p.MergeWith(file)
}
}
// MergeWith combines one project with the one specified
// as a parameter.
func (p *Project) MergeWith(file *Project) {
p.Provider = append(p.Provider, file.Provider...)
p.Global = append(p.Global, file.Global...)
p.Packages = append(p.Packages, file.Packages...)
p.Import = append(p.Import, file.Import...)
p.Templates.Template = append(p.Templates.Template, file.Templates.Template...)
p.Routes.Provide = append(p.Routes.Provide, file.Routes.Provide...)
p.Routes.Route = append(p.Routes.Route, file.Routes.Route...)
}