4

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?

4

1 回答 1

6

我花了一点时间才弄清楚这一点。安装 jscodeshift 和 material-ui codemods 后,该命令的格式应如下:

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/

我还为我的文件使用了扩展名 jsx,所以我必须添加 --extensions 标志:

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

于 2018-09-02T02:36:43.370 回答