codemod-v4
codemod-v4 copied to clipboard
忽略 .gitignore 里的目录
在 umi 3 项目中升级 antd 4 时,如下报错。

umi 3 会生成一个 src/.umi
目录,这个目录在 .gitignore
里被忽略。
// .gitignore
pids
logs
node_modules
npm-debug.log
coverage/
run
dist
public
.DS_Store
.nyc_output
.basement
config.local.js
.umi
.umi-production
www
但是还是会去跑迁移脚本,导致报错。
这边考虑读取当前项目中的 .gitignore 跟 package.json 读取策略保持一致,并与 codemod.ignore
https://github.com/ant-design/codemod-v4/blob/master/bin/codemod.ignore 合并后传给 jscodeshift
https://github.com/facebook/jscodeshift/blob/d63aa8486c2099a65b071e7c86e9dccdb8577d80/bin/jscodeshift.js#L69
根据 jscodeshift 代码来看,多传一个 --ignore-config 即可,将嗅探到的 .gitignore 路径传入
@afc163 这个不光是 gitinogre 的问题,那个 history.ts 能发出来看看没?看着是有语法解析问题
if ((<any>window).routerBase) {
options.basename = (<any>window).routerBase;
}
let history = createBrowserHistory(options);
export const createHistory = (hotReload = false) => {
if (!hotReload) {
history = createBrowserHistory(options);
}
return history;
};
<any>
泛型导致被识别成了 jsx 导致报错