Is there a way to specify end-of-line characters?
See original GitHub issueHi, I’m using Windows when my team has others using Mac.
Our .editorconfig specifies that we use \n
as EOL character, I’ve also set my .gitconfig autocrlf=input
.
So when we write test fixtures for codemods, there are \n
s in the files.
But when running tests, the output will have \r\n
s, causing tests fail on my machine.
I’m wondering if there is a way to specify EOL characters when running jscodeshift?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:7 (2 by maintainers)
Top Results From Across the Web
EOL or End of Line or newline ascii character
Press the key combination of Ctrl + Shift + F and select 'Extended' under the search mode. Now search '\r\n' - if you...
Read more >What is newline character -- '\n' - Stack Overflow
If I have to, how would I define a "newline character". say if I create a new file in unix(or windows), then does...
Read more >Newline - Wikipedia
Newline is a control character or sequence of control characters in character encoding specifications such as ASCII, EBCDIC, Unicode, etc. This character ...
Read more >Adding a Newline Character to a String in Java - Baeldung
In many cases, there is a need to add a new line to a string to format the output. Let's discuss how to...
Read more >How to: To Specify Newline Characters - EmEditor Help
The following tables show how to specify newline characters. Find Dialog box, Replace dialog box - Find, Replace with. Use Regular Expressions is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
To add to that, you can supply the following option to the CLI command to fix this broken default behavior:
Side rant: It’s really nice that you have to search through a myriad of issues and dependencies to determine that some developers arbitrarily decided that it was a good idea to use the OS line endings rather than honor the contents of the original file or default to the sane LF character. It’s further great that there is no mention of this in the README of this repo or the
react-codemod
repo to warn users of this arbitrary design decision that will likely break tests as @tw0517tw mentions.@ksummerlin Your command looks correct. Unfortunately, this works on some of the scripts, but not all. I have a PR open that consistently consumes the
printOptions
on all scripts, but it has not been reviewed yet by the collaborators:https://github.com/reactjs/react-codemod/pull/145
You can clone my existing fork and run that command again and it should work (assuming transformation still need to be made in your React files). Alternatively, you can also run the
dos2unix
command if you are using MinGW or some other Bash shell:https://stackoverflow.com/a/11929475/1532882