diff --git a/CODEOWNERS b/CODEOWNERS index 152373c..4d6e159 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1 @@ -* @beaugunderson +* @beaugunderson # I own the whole project! diff --git a/codeowners.js b/codeowners.js index 74c4678..e125ee0 100755 --- a/codeowners.js +++ b/codeowners.js @@ -59,13 +59,17 @@ function Codeowners(currentPath, fileName = 'CODEOWNERS') { continue; } - const [pathString, ...usernames] = line.split(/\s+/); + const [data, ...comment] = line.split("#"); + const [pathString, ...usernames] = data.split(/\s+/); - ownerEntries.push({ + const entry = { path: pathString, - usernames, + usernames: usernames.filter(Boolean), match: ownerMatcher(pathString), - }); + } + if(comment && comment.length) entry.comment = comment.join("") + + ownerEntries.push(entry); } // reverse the owner entries to search from bottom to top diff --git a/codeowners.test.js b/codeowners.test.js index e3e3092..17f2e57 100644 --- a/codeowners.test.js +++ b/codeowners.test.js @@ -15,4 +15,8 @@ describe('codeowners', () => { const owner = repos.getOwner(__filename); expect(owner).toEqual(['@beaugunderson']); }); + + it('respects inline comments', () => { + expect(repos.ownerEntries[0].comment).toEqual(" I own the whole project!") + }); });