@@ -119,31 +119,31 @@ class Templates {
119
119
) ;
120
120
} ;
121
121
122
+ findTemplateWithExt = ( path ) => {
123
+ const raw = this . cropExtension ( path ) ;
124
+ const pathVariants = this . config . templateExtensions . map ( ( extension ) => `${ raw } ${ extension } ` ) ;
125
+ return pathVariants . find ( ( variant ) => this . fileSystem . pathIsExist ( variant ) ) ;
126
+ } ;
127
+
122
128
getTemplateContent = ( path ) => {
123
129
const foundTemplatePathKey = _ . keys ( this . config . templatePaths ) . find ( ( key ) => _ . startsWith ( path , `@${ key } ` ) ) ;
124
130
125
- const findPathWithExt = ( path ) => {
126
- const raw = this . cropExtension ( path ) ;
127
- const pathVariants = this . config . templateExtensions . map ( ( extension ) => `${ raw } ${ extension } ` ) ;
128
- return pathVariants . find ( ( variant ) => this . fileSystem . pathIsExist ( variant ) ) ;
129
- } ;
130
-
131
131
const rawPath = resolve (
132
132
_ . replace ( path , `@${ foundTemplatePathKey } ` , this . config . templatePaths [ foundTemplatePathKey ] ) ,
133
133
) ;
134
- const fixedPath = findPathWithExt ( rawPath ) ;
134
+ const fixedPath = this . findTemplateWithExt ( rawPath ) ;
135
135
136
136
if ( fixedPath ) {
137
137
return this . fileSystem . getFileContent ( fixedPath ) ;
138
138
}
139
139
140
- const customPath = findPathWithExt ( resolve ( this . config . templatePaths . custom , path ) ) ;
140
+ const customPath = this . findTemplateWithExt ( resolve ( this . config . templatePaths . custom , path ) ) ;
141
141
142
142
if ( customPath ) {
143
143
return this . fileSystem . getFileContent ( customPath ) ;
144
144
}
145
145
146
- const originalPath = findPathWithExt ( resolve ( this . config . templatePaths . original , path ) ) ;
146
+ const originalPath = this . findTemplateWithExt ( resolve ( this . config . templatePaths . original , path ) ) ;
147
147
148
148
if ( originalPath ) {
149
149
return this . fileSystem . getFileContent ( originalPath ) ;
0 commit comments