@@ -49,7 +49,7 @@ func GetStyleResources(c *config.TemplateJson, s *config.TemplateStyle, configPa
49
49
ignoreRules = ResolveGlobs (ignoreRules , types .NewSet (".git/" ))
50
50
log .Debugf ("ignore rules: %v\n " , ignoreRules )
51
51
52
- includePaths := make (map [string ]string , len (s .Includes )) // includePath: dir
52
+ includePaths := make (map [string ]* config. TemplateInclude , len (s .Includes )) // includePath: dir
53
53
if s .Includes != nil {
54
54
for _ , includePath := range s .Includes {
55
55
log .Infof ("include path: %s\n " , includePath .Source .String ())
@@ -60,11 +60,7 @@ func GetStyleResources(c *config.TemplateJson, s *config.TemplateStyle, configPa
60
60
61
61
log .Debugf ("resolved include paths: %v\n " , inPths )
62
62
for p := range inPths {
63
- if includePath .Directory == nil {
64
- includePaths [filepath .Join (includePath .Source .String (), p )] = ""
65
- } else {
66
- includePaths [filepath .Join (includePath .Source .String (), p )] = includePath .Directory .String ()
67
- }
63
+ includePaths [filepath .Join (includePath .Source .String (), p )] = & includePath
68
64
}
69
65
}
70
66
}
@@ -87,19 +83,25 @@ func GetStyleResources(c *config.TemplateJson, s *config.TemplateStyle, configPa
87
83
88
84
resources := make ([]types.StyleResource , 0 , len (filteredPaths ))
89
85
for v := range filteredPaths {
90
- parts := strings .Split (v , "/" )
91
- projPath := strings .Join (parts [min (len (parts ), 1 ):], "/" )
86
+ var projPath string
92
87
93
- if dirPrepend , ok := includePaths [v ]; ok {
94
- projPath = filepath .Join (dirPrepend , projPath )
88
+ if include , ok := includePaths [v ]; ok {
89
+ projPath = strings .TrimPrefix (v , include .Source .String ()+ "/" )
90
+ if include .Directory != nil {
91
+ projPath = filepath .Join (include .Directory .String (), projPath )
92
+ }
95
93
96
94
// skip if found in style list
97
- searchPath := filepath .Join (s .Source .String (), projPath )
98
- if stylePaths .Contains (searchPath ) {
95
+ expectedStyleRelPath := filepath .Join (s .Source .String (), projPath )
96
+ if stylePaths .Contains (expectedStyleRelPath ) {
99
97
continue
100
98
}
101
99
}
102
100
101
+ if projPath == "" {
102
+ projPath = strings .TrimPrefix (v , s .Source .String ()+ "/" )
103
+ }
104
+
103
105
resources = append (resources , types.StyleResource {
104
106
TemplateResourceRelPath : v ,
105
107
TemplatedProjectRelPath : projPath ,
0 commit comments