Closed arai-a closed 2 years ago
Are you perchance running jscodeshift on Windows (I'm guessing that won't matter, but I'd like to rule our anything platform-specific first).
oh, sorry, I forgot to explain the context.
yes, I bumped into the issue when running jscodeshift
across OSes, and I see the behavior only on Windows.
The behavior itself you're seeing is caused by a recast issue. Recast defaults to the platform-specific line terminator.
https://github.com/benjamn/recast/issues/269
So is the issue that toSource() in your workaround isn't actually changing the line terminator used for the output?
I'm running node_modules/.bin/jscodeshift
command after npm install jscodeshift
.
instead of importing jscodeshift
from JS application.
So there's no toSource
call I can modify.
https://github.com/facebook/jscodeshift/blob/main/bin/jscodeshift.js
Possible fix is to add new command-line parameter to jscodeshift
command that receives the override for line terminator.
If the fix sounds reasonable, I'll look into fixing the command.
oh, sorry, I misunderstood the issue.
I see toSource()
call in the transform file I'm using.
Related to https://github.com/facebook/jscodeshift/issues/262 , running
jscodeshift
command on a file with LF converts the newline to CRLF, even if there's no other change.workaround posted in https://github.com/facebook/jscodeshift/issues/262#issuecomment-516563941 isn't applicable for
jscodeshift
command.