Skip to content
This repository was archived by the owner on Apr 8, 2026. It is now read-only.

Commit 375f896

Browse files
author
Phil Wills
authored
Merge pull request #5 from elijaholmos/main
fix(OwnershipEngine): not handling CRLF EOL
2 parents a2e7f6b + 3f922fe commit 375f896

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/lib/ownership/OwnershipEngine.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,16 @@ describe('OwnershipEngine', () => {
158158
expect(() => OwnershipEngine.FromCodeownersFile('some/codeowners/file'))
159159
.toThrowError(expectedError);
160160
});
161+
162+
it('should parse CRLF files (#4)', () => {
163+
// Arrange
164+
const codeowners = 'some/path @global-owner1 @org/octocat docs@example.com\r\n';
165+
166+
readFileSyncMock.mockReturnValue(Buffer.from(codeowners));
167+
168+
// Assert
169+
expect(() => OwnershipEngine.FromCodeownersFile('some/codeowners/file')).not.toThrow();
170+
});
161171
});
162172

163173
describe.each<any>(patterns)('$name: "$pattern"', ({ name, pattern, paths }) => {

src/lib/ownership/OwnershipEngine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class OwnershipEngine {
4141

4242
public static FromCodeownersFile(filePath: string) {
4343
try {
44-
const lines = fs.readFileSync(filePath).toString().split('\n');
44+
const lines = fs.readFileSync(filePath).toString().replace(/\r/g, '').split('\n');
4545

4646
const owned: FileOwnershipMatcher[] = [];
4747

0 commit comments

Comments
 (0)