This can cause every single line in the original file appear changed if you're using Windows to run a codemod on a file that was originally written in Mac\Linux, or vice-versa.
(As a Windows user, most of the open source-code I depend on uses \n and not \r\n because it was not written on Windows, so this is quite a common scenario for me).
Is it possible to make recast infer the original EOL marker based on the original file, like it does for tabWidth?
Thank you!
Full disclosure: I didn't run recast directly but rather via jscodeshift, but I'm assuming this is still the relevant repo to address this issue.
Please LMK if you need any further clarifications from me.
Would be happy to take a swing at submitting a PR with some guidance as to how this could be achieved.
Hi.
Recast chooses the
lineTerminator
to use based on the default end-of-line marker of the host OS. See this line: https://github.com/benjamn/recast/blob/539d044ef2d295878e056f6b5c9648a7c05f9823/lib/options.js#L21This can cause every single line in the original file appear changed if you're using Windows to run a codemod on a file that was originally written in Mac\Linux, or vice-versa. (As a Windows user, most of the open source-code I depend on uses
\n
and not\r\n
because it was not written on Windows, so this is quite a common scenario for me).Is it possible to make recast infer the original EOL marker based on the original file, like it does for
tabWidth
?Thank you!
Full disclosure: I didn't run
recast
directly but rather viajscodeshift
, but I'm assuming this is still the relevant repo to address this issue.Please LMK if you need any further clarifications from me. Would be happy to take a swing at submitting a PR with some guidance as to how this could be achieved.