Skip to content

Excluding files/folders in .gitignore from ava-files. Fixes #1229 #1250

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

Closed
wants to merge 2 commits into from
Closed
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
5 changes: 3 additions & 2 deletions lib/ava-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ function handlePaths(files, excludePatterns, globOptions) {
const defaultExcludePatterns = () => [
'!**/node_modules/**',
'!**/fixtures/**',
'!**/helpers/**'
'!**/helpers/**',
'!**/.gitignore/**'
];

const defaultIncludePatterns = () => [
Expand Down Expand Up @@ -135,7 +136,7 @@ class AvaFiles {
});
}
findTestHelpers() {
return handlePaths(defaultHelperPatterns(), ['!**/node_modules/**'], {
return handlePaths(defaultHelperPatterns(), ['!**/node_modules/**', '!**/.gitignore/**'], {
cwd: this.cwd,
includeUnderscoredFiles: true,
cache: Object.create(null),
Expand Down
12 changes: 12 additions & 0 deletions test/ava-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ test('sourceMatcher - defaults', t => {
isSource('bar.js');
isSource('bar/bar.js');
notSource('node_modules/foo.js');
notSource('.gitignore/foo.js');
t.end();
});

Expand All @@ -96,6 +97,17 @@ test('sourceMatcher - allow matching specific node_modules directories', t => {
t.end();
});

test('sourceMatcher - allow matching specific node_modules directories', t => {
const avaFiles = new AvaFiles({
files: ['**/foo*'],
sources: ['.gitignore/foo/**']
});

t.true(avaFiles.isSource('.gitignore/foo/foo.js'));
t.false(avaFiles.isSource('.gitignore/bar/foo.js'));
t.end();
});

test('sourceMatcher - providing negation patterns', t => {
const avaFiles = new AvaFiles({
files: ['**/foo*'],
Expand Down