Skip to content
Open
Changes from all commits
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
12 changes: 10 additions & 2 deletions codeowners.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ const ignore = require('ignore');
const isDirectory = require('is-directory');
const path = require('path');
const trueCasePath = require('true-case-path');
const checkPaths = [
'.bitbucket/',
'.github/',
'.gitlab/',
'docs/',
''
];

function ownerMatcher(pathString) {
const matcher = ignore().add(pathString);
Expand All @@ -16,7 +23,7 @@ function Codeowners(currentPath, fileName = 'CODEOWNERS') {
const pathOrCwd = currentPath || process.cwd();

const codeownersPath = findUp.sync(
[`.github/${fileName}`, `.gitlab/${fileName}`, `docs/${fileName}`, `${fileName}`],
checkPaths.map(checkPath => `${checkPath}${fileName}`),
{ cwd: pathOrCwd }
);

Expand All @@ -30,7 +37,8 @@ function Codeowners(currentPath, fileName = 'CODEOWNERS') {

// We might have found a bare codeowners file or one inside the three supported subdirectories.
// In the latter case the project root is up another level.
if (this.codeownersDirectory.match(/\/(.github|.gitlab|docs)$/i)) {
// @TODO Use the checkPaths array to build this regex or otherwise do the test/match.
if (this.codeownersDirectory.match(/\/(.github|.gitlab|docs|.bitbucket)$/i)) {
this.codeownersDirectory = path.dirname(this.codeownersDirectory);
}

Expand Down