VikR
VikR

Reputation: 5142

Material-UI Migration Helper: codemod-script?

I'm updating from Material-UI 0.x to 1.0.

The docs for migration-helper say to run:

 jscodeshift -t <codemod-script> <path>. 

I've never used jscodeshift before, and I've never seen the notation before, so I would like to get some advice on how to use this. :) Googling jscodeshift codemod-script brings up nothing relevant.

What does codemod-script need to be?

Upvotes: 4

Views: 1421

Answers (1)

Michael Cook
Michael Cook

Reputation: 1707

It took me a bit to figure this out. After you've installed jscodeshift and the material-ui codemods, the command should be formatted as follows:

jscodeshift -t <the file path of the specific code mod file> <the location of the files you want to process>

jscodeshift -t ./node_modules/@material-ui/codemod/lib/v1.0.0/svg-icon-imports.js ./src/

I also use the extension jsx for my files so I had to add the --extensions flag:

jscodeshift -t ./node_modules/@material-ui/codemod/lib/v1.0.0/svg-icon-imports.js ./src/ --extensions jsx

Upvotes: 6

Related Questions