1
- import { resolve } from "node:path" ;
2
1
import * as path from "node:path" ;
3
2
import * as url from "node:url" ;
4
3
import * as Eta from "eta" ;
@@ -36,14 +35,21 @@ class TemplatesWorker {
36
35
*/
37
36
getTemplatePaths = ( config ) => {
38
37
const __dirname = path . dirname ( url . fileURLToPath ( import . meta. url ) ) ;
39
- const baseTemplatesPath = resolve ( __dirname , "../templates/base" ) ;
40
- const defaultTemplatesPath = resolve ( __dirname , "../templates/default" ) ;
41
- const modularTemplatesPath = resolve ( __dirname , "../templates/modular" ) ;
38
+ const baseTemplatesPath = path . resolve ( __dirname , "../templates/base" ) ;
39
+ const defaultTemplatesPath = path . resolve (
40
+ __dirname ,
41
+ "../templates/default" ,
42
+ ) ;
43
+ const modularTemplatesPath = path . resolve (
44
+ __dirname ,
45
+ "../templates/modular" ,
46
+ ) ;
42
47
const originalTemplatesPath = config . modular
43
48
? modularTemplatesPath
44
49
: defaultTemplatesPath ;
45
50
const customTemplatesPath =
46
- ( config . templates && resolve ( process . cwd ( ) , config . templates ) ) || null ;
51
+ ( config . templates && path . resolve ( process . cwd ( ) , config . templates ) ) ||
52
+ null ;
47
53
48
54
return {
49
55
/** `templates/base` */
@@ -65,8 +71,8 @@ class TemplatesWorker {
65
71
path ,
66
72
) ;
67
73
68
- getTemplateFullPath = ( path , fileName ) => {
69
- const raw = resolve ( path , "./" , this . cropExtension ( fileName ) ) ;
74
+ getTemplateFullPath = ( path_ , fileName ) => {
75
+ const raw = path . resolve ( path_ , "./" , this . cropExtension ( fileName ) ) ;
70
76
const pathVariants = this . config . templateExtensions . map (
71
77
( extension ) => `${ raw } ${ extension } ` ,
72
78
) ;
@@ -171,13 +177,13 @@ class TemplatesWorker {
171
177
return pathVariants . find ( ( variant ) => this . fileSystem . pathIsExist ( variant ) ) ;
172
178
} ;
173
179
174
- getTemplateContent = ( path ) => {
180
+ getTemplateContent = ( path_ ) => {
175
181
const foundTemplatePathKey = lodash
176
182
. keys ( this . config . templatePaths )
177
- . find ( ( key ) => path . startsWith ( `@${ key } ` ) ) ;
183
+ . find ( ( key ) => path_ . startsWith ( `@${ key } ` ) ) ;
178
184
179
- const rawPath = resolve (
180
- path . replace (
185
+ const rawPath = path . resolve (
186
+ path_ . replace (
181
187
`@${ foundTemplatePathKey } ` ,
182
188
this . config . templatePaths [ foundTemplatePathKey ] ,
183
189
) ,
@@ -190,14 +196,16 @@ class TemplatesWorker {
190
196
191
197
const customPath =
192
198
this . config . templatePaths . custom &&
193
- this . findTemplateWithExt ( resolve ( this . config . templatePaths . custom , path ) ) ;
199
+ this . findTemplateWithExt (
200
+ path . resolve ( this . config . templatePaths . custom , path_ ) ,
201
+ ) ;
194
202
195
203
if ( customPath ) {
196
204
return this . fileSystem . getFileContent ( customPath ) ;
197
205
}
198
206
199
207
const originalPath = this . findTemplateWithExt (
200
- resolve ( this . config . templatePaths . original , path ) ,
208
+ path . resolve ( this . config . templatePaths . original , path_ ) ,
201
209
) ;
202
210
203
211
if ( originalPath ) {
0 commit comments