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

fix(cli): improve handling of Windows CRLF line endings #25

Merged
merged 4 commits into from
Apr 23, 2024

Conversation

aloisklink
Copy link
Contributor

Fixes a regex that was incorrectly breaking up '\r\n'/CRLF/␍␊ line-breaks (commonly used in Windows OSes) to just plain '\r'. And it seems like the YAML library we're using: https://www.npmjs.com/package/yaml seems to not register just \r as a line-break (although the YAML Spec v1.2.2 § 5.4 Line Break Characters does seem to say that either \r, '\n' or '\r\n' can be used as a line break).

On Windows, files are normally checked-out with git config core.autocrlf true, which will replace '\n'/LF/␊ chars with '\r\n'/CRLF/␍␊ chars. We should also handle this in our unit tests, otherwise tests will fail on Windows.

On Windows, lines usually end with `\r\n`/CRLF/␍␊.

Although YAML supports this as a line-break, our regex was incorrectly
breaking this up, which was causing the `\r` character to be appending
into some strings, instead of `\r\n`.
On Windows, files are normally checked-out with
`git config core.autocrlf true`, which will replace `'\n'`/LF chars
with `'\r\n'`/CRLF chars. We should handle this in our unit tests,
otherwise tests will fail on Windows CI.
Updates the newly created `packages/cli/CHANGELOG.md` file.
@aloisklink aloisklink added the bug Something isn't working label Apr 23, 2024
Copy link

vercel bot commented Apr 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated (UTC)
office-plugin-site ⬜️ Ignored (Inspect) Apr 23, 2024 6:24am

@aloisklink aloisklink merged commit 5e20ece into main Apr 23, 2024
14 checks passed
@aloisklink aloisklink deleted the fix/fix-CRLF-windows-issue branch April 23, 2024 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants