1- import { resolve } from "node:path" ;
21import * as path from "node:path" ;
32import * as url from "node:url" ;
43import * as Eta from "eta" ;
@@ -36,14 +35,21 @@ class TemplatesWorker {
3635 */
3736 getTemplatePaths = ( config ) => {
3837 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+ ) ;
4247 const originalTemplatesPath = config . modular
4348 ? modularTemplatesPath
4449 : defaultTemplatesPath ;
4550 const customTemplatesPath =
46- ( config . templates && resolve ( process . cwd ( ) , config . templates ) ) || null ;
51+ ( config . templates && path . resolve ( process . cwd ( ) , config . templates ) ) ||
52+ null ;
4753
4854 return {
4955 /** `templates/base` */
@@ -65,8 +71,8 @@ class TemplatesWorker {
6571 path ,
6672 ) ;
6773
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 ) ) ;
7076 const pathVariants = this . config . templateExtensions . map (
7177 ( extension ) => `${ raw } ${ extension } ` ,
7278 ) ;
@@ -171,13 +177,13 @@ class TemplatesWorker {
171177 return pathVariants . find ( ( variant ) => this . fileSystem . pathIsExist ( variant ) ) ;
172178 } ;
173179
174- getTemplateContent = ( path ) => {
180+ getTemplateContent = ( path_ ) => {
175181 const foundTemplatePathKey = lodash
176182 . keys ( this . config . templatePaths )
177- . find ( ( key ) => path . startsWith ( `@${ key } ` ) ) ;
183+ . find ( ( key ) => path_ . startsWith ( `@${ key } ` ) ) ;
178184
179- const rawPath = resolve (
180- path . replace (
185+ const rawPath = path . resolve (
186+ path_ . replace (
181187 `@${ foundTemplatePathKey } ` ,
182188 this . config . templatePaths [ foundTemplatePathKey ] ,
183189 ) ,
@@ -190,14 +196,16 @@ class TemplatesWorker {
190196
191197 const customPath =
192198 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+ ) ;
194202
195203 if ( customPath ) {
196204 return this . fileSystem . getFileContent ( customPath ) ;
197205 }
198206
199207 const originalPath = this . findTemplateWithExt (
200- resolve ( this . config . templatePaths . original , path ) ,
208+ path . resolve ( this . config . templatePaths . original , path_ ) ,
201209 ) ;
202210
203211 if ( originalPath ) {
0 commit comments