File tree Expand file tree Collapse file tree 1 file changed +35
-8
lines changed
packages/rtk-codemods/bin Expand file tree Collapse file tree 1 file changed +35
-8
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env node
2
- const path = require ( 'path' ) ;
2
+ import { execaSync } from 'execa'
3
+ import { globbySync } from 'globby'
4
+ import { createRequire } from 'node:module'
5
+ import path from 'node:path'
6
+ import { fileURLToPath } from 'node:url'
3
7
4
- require ( 'ts-node' ) . register ( {
5
- project : path . join ( __dirname , './tsconfig.json' ) ,
6
- } ) ;
8
+ const require = createRequire ( import . meta. url )
7
9
8
- require ( 'codemod-cli' ) . runTransform (
10
+ const __filename = fileURLToPath ( import . meta. url )
11
+ const __dirname = path . dirname ( __filename )
12
+
13
+ const transformerDirectory = path . join (
9
14
__dirname ,
10
- process . argv [ 2 ] /* transform name */ ,
11
- process . argv . slice ( 3 ) /* paths or globs */
12
- ) ;
15
+ '..' ,
16
+ 'transforms' ,
17
+ `${ process . argv [ 2 ] } /index.ts`
18
+ )
19
+
20
+ const jscodeshiftExecutable = require . resolve ( '.bin/jscodeshift' )
21
+
22
+ const extensions = 'ts,js,tsx,jsx'
23
+
24
+ execaSync (
25
+ jscodeshiftExecutable ,
26
+ [
27
+ '-t' ,
28
+ transformerDirectory ,
29
+ '--extensions' ,
30
+ extensions ,
31
+ ...( process . argv . slice ( 3 ) . length === 1
32
+ ? globbySync ( process . argv [ 3 ] )
33
+ : process . argv . slice ( 3 ) )
34
+ ] ,
35
+ {
36
+ stdio : 'inherit' ,
37
+ stripFinalNewline : false
38
+ }
39
+ )
You can’t perform that action at this time.
0 commit comments