代码之家  ›  专栏  ›  技术社区  ›  VikR

材质UI迁移助手:codemod脚本?

  •  1
  • VikR  · 技术社区  · 8 年前

    我正在从材料UI 0.x更新到1.0。

    文件 migration-helper 说要跑:

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

    我以前从未使用过jscodeshift,也从未见过这种符号,所以我想得到一些关于如何使用它的建议。:)谷歌搜索 jscodeshift codemod-script 没有任何相关信息。

    做什么 codemod-script 需要吗?

    1 回复  |  直到 8 年前
        1
  •  5
  •   Michael Cook    8 年前

    我花了点时间才弄明白。安装jscodeshift和材料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

    推荐文章