codemod-v4 icon indicating copy to clipboard operation
codemod-v4 copied to clipboard

the way that jscodeshift read gitignore is not correct

Open vagusX opened this issue 4 years ago • 4 comments

https://github.com/facebook/jscodeshift/blob/5a6a868433d7e27104d02b1a90917adc0b47589a/src/ignoreFiles.js#L54

vagusX avatar Mar 29 '20 14:03 vagusX

没有合理处理 ! negative part

function shouldIgnore(path) {
  const matched = matchers.length ? mm.any(path, matchers, { dot:true }) : false;
  return matched;
}

mm.any('src/index.tsx', ['**/!a.tsx','!a.tsx' ], { dot: true }) // true

vagusX avatar Mar 29 '20 14:03 vagusX

@afc163 我考虑先禁用掉 gitignore 的读取,因为上面 minimatch 的规则貌似有点不太对劲,待进一步深入解决,然后我先把 .umi 等加到 ignore config 里面,

vagusX avatar Mar 30 '20 05:03 vagusX

试试 https://www.npmjs.com/package/globby#globbygitignoreoptions ?

afc163 avatar Mar 30 '20 05:03 afc163

试试 https://www.npmjs.com/package/globby#globbygitignoreoptions ?

minimatch 是 jscodeshift 自己内部用的,我这边是发现他读取 gitignore 是不对的,好几个项目他把所有的 js 文件都 ignore 掉了

vagusX avatar Mar 30 '20 05:03 vagusX