@@ -103,14 +103,20 @@ export function initDirectory(
103103 targetPath : string = './' ,
104104 isReduced : boolean = false ,
105105) {
106- const basePath = `${ targetPath } /${ packageName . replace ( '/' , '__' ) } ` ;
107- const configPath = `${ basePath } ${
108- ! isReduced ? '/src' : ''
109- } /codeshift.config.js`;
106+ const basePath = path . join ( targetPath , packageName . replace ( '/' , '__' ) ) ;
107+ const configPath = path . join (
108+ basePath ,
109+ ! isReduced ? 'src' : '' ,
110+ 'codeshift.config.js' ,
111+ ) ;
110112
111- fs . copySync ( `${ __dirname } /../template${ isReduced ? '/src' : '' } ` , basePath , {
112- filter : src => ! src . includes ( 'src/codemod' ) ,
113- } ) ;
113+ fs . copySync (
114+ path . join ( __dirname , '..' , 'template' , isReduced ? 'src' : '' ) ,
115+ basePath ,
116+ {
117+ filter : src => ! src . includes ( 'src/codemod' ) ,
118+ } ,
119+ ) ;
114120
115121 if ( ! isReduced ) {
116122 fs . writeFileSync (
@@ -135,19 +141,24 @@ export function initTransform(
135141 throw new Error ( `Provided version ${ id } is not a valid semver version` ) ;
136142 }
137143
138- const basePath = `${ targetPath } /${ packageName . replace ( '/' , '__' ) } ` ;
139- const transformPath = `${ basePath } ${ ! isReduced ? '/src' : '' } /${ id } ` ;
140- const configPath = `${ basePath } ${
141- ! isReduced ? '/src' : ''
142- } /codeshift.config.js`;
144+ const basePath = path . join ( targetPath , packageName . replace ( '/' , '__' ) ) ;
145+ const transformPath = path . join ( basePath , ! isReduced ? 'src' : '' , id ) ;
146+ const configPath = path . join (
147+ basePath ,
148+ ! isReduced ? 'src' : '' ,
149+ 'codeshift.config.js' ,
150+ ) ;
143151
144152 if ( fs . existsSync ( transformPath ) ) {
145153 throw new Error ( `Codemod for ${ type } "${ id } " already exists` ) ;
146154 }
147155
148- fs . copySync ( `${ __dirname } /../template${ isReduced ? '/src' : '' } ` , basePath ) ;
156+ fs . copySync (
157+ path . join ( __dirname , '..' , 'template' , isReduced ? 'src' : '' ) ,
158+ basePath ,
159+ ) ;
149160 fs . renameSync (
150- ` ${ basePath } ${ ! isReduced ? '/ src' : '' } / codemod` ,
161+ path . join ( basePath , ! isReduced ? 'src' : '' , ' codemod' ) ,
151162 transformPath ,
152163 ) ;
153164
0 commit comments