-
Notifications
You must be signed in to change notification settings - Fork 0
/
module.go
58 lines (46 loc) · 1022 Bytes
/
module.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
57
58
package valueobject
import (
"github.com/gohugonet/hugoverse/internal/domain/module"
"github.com/spf13/afero"
"path/filepath"
)
type Modules []*Module
type Module struct {
AbsDir string
Fs afero.Fs
Path string
Parent *Module
MountDirs []Mount
// Go Module supported only
*GoModule
}
func (m *Module) ApplyMounts(moduleImport Import) error {
mounts := moduleImport.Mounts
if len(mounts) == 0 {
for _, componentFolder := range module.ComponentFolders {
sourceDir := filepath.Join(m.AbsDir, componentFolder)
_, err := m.Fs.Stat(sourceDir)
if err == nil {
mounts = append(mounts, Mount{
SourcePath: componentFolder,
TargetPath: componentFolder,
})
}
}
}
m.MountDirs = mounts
return nil
}
func (m *Module) Owner() module.Module {
return m.Parent
}
func (m *Module) Mounts() []module.Mount {
var mounts []module.Mount
for _, mount := range m.MountDirs {
mounts = append(mounts, mount)
}
return mounts
}
func (m *Module) Dir() string {
return m.AbsDir
}