question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a way to specify end-of-line characters?

See original GitHub issue

Hi, 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 \ns in the files. But when running tests, the output will have \r\ns, causing tests fail on my machine.

I’m wondering if there is a way to specify EOL characters when running jscodeshift?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:8
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
jakezateckycommented, May 12, 2017

To add to that, you can supply the following option to the CLI command to fix this broken default behavior:

--printOptions='{"lineTerminator":"\n"}'

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.

1reaction
jakezateckycommented, May 23, 2017

@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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found