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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test(cli): handle CRLF in test fixture files
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.
  • Loading branch information
aloisklink committed Apr 23, 2024
commit dce5bfaa7f4f64d77fd372b269784b0d0508f83c
6 changes: 4 additions & 2 deletions packages/cli/src/commander.test.ts
Original file line number Diff line number Diff line change
@@ -390,8 +390,10 @@ describe('link', () => {
expect(file).toMatch(idLineRegex);
// other than the added `id: xxxx` field, everything else should be identical,
// although in practice, we'd expect some formatting changes
expect(file.replace(idLineRegex, '')).toStrictEqual(
await readFile(UNUSUAL_MARKDOWN_FILE, { encoding: 'utf8' }),
//
// We also normalize line endings to LF to avoid issues with CRLF on Windows
expect(file.replace(idLineRegex, '').replaceAll('\r\n', '\n')).toStrictEqual(
(await readFile(UNUSUAL_MARKDOWN_FILE, { encoding: 'utf8' })).replaceAll('\r\n', '\n'),
);
});
});
Loading
Oops, something went wrong.