Skip to content
Open
Show file tree
Hide file tree
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
15 changes: 14 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ program
.command('audit')
.description('list the owners for all files')
.option('-u, --unowned', 'unowned files only')
.option('-i, --include-ignored', 'include files in .gitignore (excluded by default)')
.option('-w, --width <columns>', 'how much should filenames be padded?', '32')
.option(
'-c, --codeowners-filename <codeowners_filename>',
Expand All @@ -48,7 +49,9 @@ program
const stream = walkStream(rootPath, {
deepFilter: (entry) => {
const split = entry.path.split(path.sep);
return !split.includes('node_modules') && !split.includes('.git') && !split.includes('.cache');
return (
!split.includes('node_modules') && !split.includes('.git') && !split.includes('.cache')
);
},
errorFilter: (error) =>
error.code === 'ENOENT' || error.code === 'EACCES' || error.code === 'EPERM',
Expand All @@ -61,6 +64,16 @@ program

const owners = codeowners.getOwner(relative);

// if --include-ignored is not specified and we found a .gitignore file
// then check the relative path against the .gitignore matcher
if (!options.includeIgnored && gitignorePath) {
const relativePath = path.relative(gitignorePath, file.path);

if (gitignoreMatcher.ignores(relativePath)) {
return;
}
}

if (options.unowned) {
if (!owners.length) {
console.log(relative);
Expand Down
Loading