@@ -103,14 +103,20 @@ export function initDirectory(
103
103
targetPath : string = './' ,
104
104
isReduced : boolean = false ,
105
105
) {
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
+ ) ;
110
112
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
+ ) ;
114
120
115
121
if ( ! isReduced ) {
116
122
fs . writeFileSync (
@@ -135,19 +141,24 @@ export function initTransform(
135
141
throw new Error ( `Provided version ${ id } is not a valid semver version` ) ;
136
142
}
137
143
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
+ ) ;
143
151
144
152
if ( fs . existsSync ( transformPath ) ) {
145
153
throw new Error ( `Codemod for ${ type } "${ id } " already exists` ) ;
146
154
}
147
155
148
- fs . copySync ( `${ __dirname } /../template${ isReduced ? '/src' : '' } ` , basePath ) ;
156
+ fs . copySync (
157
+ path . join ( __dirname , '..' , 'template' , isReduced ? 'src' : '' ) ,
158
+ basePath ,
159
+ ) ;
149
160
fs . renameSync (
150
- ` ${ basePath } ${ ! isReduced ? '/ src' : '' } / codemod` ,
161
+ path . join ( basePath , ! isReduced ? 'src' : '' , ' codemod' ) ,
151
162
transformPath ,
152
163
) ;
153
164
0 commit comments