Closed constgen closed 4 years ago
May be (I am not sure) it will fix it in my personal environment. But it will not save other developers from this issue. The good practice is to keep everything always in LF. But I have no idea where CRLF are generated from. What is also interesting that the half of the generated file is LF and the another half is CRLF
Another option: do you think we can apply local Git configs and commit them to the repository?
Yeah the SO link has suggestions for how to set up a .gitattributes
file, which gets committed to the repo and tells git to ignore the global settings the user might have and check out the code with the desired line endings.
Turned out the issue comes from absolutely another side https://github.com/facebook/jscodeshift/issues/195 . Recast (the nested dependency) automatically chooses OS end of line for code generation.
I tried --printOptions='{"lineTerminator":"\n"}'
in the test. And the problem is that even with the flag the generated output is not affected. Actually no of known printOptions
affect anything. Seems like they are not applied at all. They say they resolved this issue but I can still reproduce ignoring of printOptions
in CLI
Have no idea how to make it work. The only options are to redesign the test or disable testing on commit as they block. PRs will be still tested on CI
Bug
Here is the output from the CLI
CRLF - is code generated from
migrate
LF - is code generated frompackages\migrate\test\fixtures\.neutrinorc.js.txt
The full output from the CLI
I believe this happens due to Git auto conversion of line endings (Git client feature) during cloning and commit. But I may be wrong. Any ideas how to fix this?