Skip to content

Commit

Permalink
fix: do not ignore negative patterns for patterns outside cwd
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmlnc committed Jul 7, 2021
1 parent d22afc5 commit 8a3e6d6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/managers/tasks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('Managers → Task', () => {

it('should return two tasks when one of patterns contains reference to the parent directory', () => {
const expected = [
tests.task.builder().base('..').positive('../*.md').build(),
tests.task.builder().base('..').positive('../*.md').negative('*.md').build(),
tests.task.builder().base('.').positive('*').positive('a/*').negative('*.md').build()
];

Expand Down
2 changes: 1 addition & 1 deletion src/managers/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function convertPatternsToTasks(positive: Pattern[], negative: Pattern[],
const outsideCurrentDirectoryGroup = groupPatternsByBaseDirectory(patternsOutsideCurrentDirectory);
const insideCurrentDirectoryGroup = groupPatternsByBaseDirectory(patternsInsideCurrentDirectory);

tasks.push(...convertPatternGroupsToTasks(outsideCurrentDirectoryGroup, [], dynamic));
tasks.push(...convertPatternGroupsToTasks(outsideCurrentDirectoryGroup, negative, dynamic));

/*
* For the sake of reducing future accesses to the file system, we merge all tasks within the current directory
Expand Down
21 changes: 21 additions & 0 deletions src/tests/smoke/regular.smoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,3 +483,24 @@ smoke.suite('Smoke → Regular (relative)', [
{ pattern: '../{first,second}', cwd: 'fixtures/first' },
{ pattern: './../*', cwd: 'fixtures/first' }
]);

smoke.suite('Smoke → Regular (relative & ignore)', [
{
pattern: './../*',
cwd: 'fixtures/first',
ignore: '../*',
correct: true,
reason: 'The `node-glob` package does not exclude files, although the `../*` pattern can be applied here.'
},
{ pattern: './../*', cwd: 'fixtures/first', ignore: './../*' },
{ pattern: './../*', cwd: 'fixtures/first', ignore: '**' },

{ pattern: '../*', cwd: 'fixtures/first', ignore: '../*' },
{ pattern: '../*', cwd: 'fixtures/first', ignore: '**' },

{ pattern: '../../*', cwd: 'fixtures/first/nested', ignore: '../../*' },
{ pattern: '../../*', cwd: 'fixtures/first/nested', ignore: '**' },

{ pattern: '../{first,second}', cwd: 'fixtures/first', ignore: '../first/**' },
{ pattern: '../{first,second}', cwd: 'fixtures/first', ignore: '**/first/**' }
]);

0 comments on commit 8a3e6d6

Please sign in to comment.