Skip to content
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

Normalize line endings #8

Merged
merged 1 commit into from
Mar 12, 2020
Merged

Normalize line endings #8

merged 1 commit into from
Mar 12, 2020

Conversation

danez
Copy link
Contributor

@danez danez commented Feb 24, 2020

Currently on unix machines this package cannot be used because it fails with

$ node_modules/.bin/browserslist-ga-export --ignoreRows 0 --reportPath browserslist-stats.csv --outputPath browserslist-stats.json
/usr/bin/env: ‘node\r’: No such file or directory

it seems the released file is with windows line endings. I added a .gitattributes file that should make sure it is checked out correctly before releasing.

Can you then please try releasing a patch with this again?

@galvarez421
Copy link
Member

Thank you for finding and reporting this issue!

I'm still learning some more about .gitattributes and thinking through this.

One concern I have is that .gitattributes doesn't ensure that the correct line endings will be published. For example, I could (inadvertently) set the line endings to CRLF locally and then publish the package. I encountered this issue when I cloned your fork and then checked out the patch- branch. Apparently, the gitattributes are not respected when switching branches as described in https://stackoverflow.com/questions/54094627/gitattributes-gets-ignored-on-checkout. This may be expected behavior, as the docs state that setting eol=lf "forces Git to normalize line endings to LF on checkin and prevents conversion to CRLF when the file is checked out.", not that the line endings will be converted to LF on checkout.

How do you feel about the addition of a prepublish script to package.json that would set LF line endings on index.js as described in npm/npm#12371 (comment)? I feel like this might address the root cause of the publish issue more directly and reliably. We could use a package like https://www.npmjs.com/package/eol perhaps?

@danez
Copy link
Contributor Author

danez commented Feb 26, 2020

Okay I will change the pr. Should I leave the gitatteibutes file in or remove it instead?

@galvarez421
Copy link
Member

Thanks! Please remove the .gitattributes file for now. Also, we may want to use prepublishOnly instead of prepublish, because the latter seems to be deprecated and the former seems to be the appropriate script to use in this case per https://docs.npmjs.com/misc/scripts#deprecation-note.

@danez
Copy link
Contributor Author

danez commented Mar 11, 2020

Ok finally came around to fix this up.

@galvarez421 galvarez421 changed the base branch from master to develop March 12, 2020 01:14
@galvarez421 galvarez421 linked an issue Mar 12, 2020 that may be closed by this pull request
@galvarez421
Copy link
Member

Thank you for your contribution!

@galvarez421 galvarez421 merged commit eb09c23 into browserslist:develop Mar 12, 2020
@galvarez421
Copy link
Member

@danez danez deleted the patch-1 branch March 12, 2020 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bin script should be published with Unix line endings
2 participants