-
Notifications
You must be signed in to change notification settings - Fork 804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EOL semantics by adding .gitattributes and changing tsconfig.json #1550
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1550 +/- ##
==========================================
- Coverage 93.18% 93.16% -0.03%
==========================================
Files 156 156
Lines 4854 4854
Branches 986 986
==========================================
- Hits 4523 4522 -1
- Misses 331 332 +1
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you se the option inside the tsconfig.base
inside the packages
folder instead ?
Alright I moved the option into the tsconfig.base instead. I noticed that some of the tsconfig.json files import from the tsconfig.es5 file instead of the tsconfig.base... would it make sense to add the option into tsconfig.es5 as well? |
@MarkSeufert Yeah i thinks so |
I think
\n instead os.EOL .os.EOL is CRLF on windows and LF on unixes.\n is LF independent of OS used.
|
This script only writes the TS files which can have an OS specific line ending I believe which will be converted by git. The output JS will still only use LF. |
As far as I remember it's a good idea to use |
The target of this PR is to have *.ts files with LF only after a fresh checkout independent of OS. The version script should not write OS dependent line endings then. |
Right... I forgot that was a regex haha |
@MarkSeufert can you take care of this? |
I ran |
… semantic Apply the same changes as in open-telemetry/opentelemetry-js#1550 in this repo to improve OS independent development.
… semantic (#286) Apply the same changes as in open-telemetry/opentelemetry-js#1550 in this repo to improve OS independent development.
…en-telemetry#1550) * style(opentelemetry-js): .gitattribute and tsconfig changes for EOL normalization * fix(opentelemetry-js): moved 'newLine': 'LF' into tsconfig.base instead of individual * fix(opentelemetry-js): changed version script to use LF instead of OS.EOL * fix(opentelemetry-js): simplified version script
…en-telemetry#1550) * style(opentelemetry-js): .gitattribute and tsconfig changes for EOL normalization * fix(opentelemetry-js): moved 'newLine': 'LF' into tsconfig.base instead of individual * fix(opentelemetry-js): changed version script to use LF instead of OS.EOL * fix(opentelemetry-js): simplified version script
Description:
This PR solves issue #1529, which addresses the non-normality of end-of-line (EOL) semantics between operating systems. There are two main concerns in this issue:
The version script uses
os.EOL
. On windows, EOL could mean either CRLF or LF depending on the git setting of autocrlf. On Linux and Mac,os.EOL
means LF.To solve this, a .gitattributes file was added in the root directory which specifies the EOL semantics for certain types of files. OS independent files should always use LF, whereas windows specific files (.bat, .cmd, etc) should use CRLF. To show that this works, I ran
npm install
on a windows machine and viewed one of the resultingversion.ts
files. This can be seen below:I then pushed it to my branch to trigger the .gitattributes functionality and then viewed the same
version.ts
file, seen below:Notice how the new file only uses LF instead of CRLF. Success!
The generated js files have inconsistent line endings, which causes differences between an npm module that is published on windows instead of on linux. To solve this, I found all the tsconfig.json files and added a single line:
"newLine": "LF"
. This means that all the generated js files inside thenode_modules
folders will use LF as their EOL.