Skip to content

Commit c64bb1e

Browse files
authored
Merge pull request #326 from mrmlnc/ISSUE-325_fix_relative_ignore_patterns
ISSUE-325: do not ignore negative patterns for patterns outside cwd
2 parents d22afc5 + 8a3e6d6 commit c64bb1e

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

src/managers/tasks.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('Managers → Task', () => {
5959

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

src/managers/tasks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function convertPatternsToTasks(positive: Pattern[], negative: Pattern[],
3838
const outsideCurrentDirectoryGroup = groupPatternsByBaseDirectory(patternsOutsideCurrentDirectory);
3939
const insideCurrentDirectoryGroup = groupPatternsByBaseDirectory(patternsInsideCurrentDirectory);
4040

41-
tasks.push(...convertPatternGroupsToTasks(outsideCurrentDirectoryGroup, [], dynamic));
41+
tasks.push(...convertPatternGroupsToTasks(outsideCurrentDirectoryGroup, negative, dynamic));
4242

4343
/*
4444
* For the sake of reducing future accesses to the file system, we merge all tasks within the current directory

src/tests/smoke/regular.smoke.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,3 +483,24 @@ smoke.suite('Smoke → Regular (relative)', [
483483
{ pattern: '../{first,second}', cwd: 'fixtures/first' },
484484
{ pattern: './../*', cwd: 'fixtures/first' }
485485
]);
486+
487+
smoke.suite('Smoke → Regular (relative & ignore)', [
488+
{
489+
pattern: './../*',
490+
cwd: 'fixtures/first',
491+
ignore: '../*',
492+
correct: true,
493+
reason: 'The `node-glob` package does not exclude files, although the `../*` pattern can be applied here.'
494+
},
495+
{ pattern: './../*', cwd: 'fixtures/first', ignore: './../*' },
496+
{ pattern: './../*', cwd: 'fixtures/first', ignore: '**' },
497+
498+
{ pattern: '../*', cwd: 'fixtures/first', ignore: '../*' },
499+
{ pattern: '../*', cwd: 'fixtures/first', ignore: '**' },
500+
501+
{ pattern: '../../*', cwd: 'fixtures/first/nested', ignore: '../../*' },
502+
{ pattern: '../../*', cwd: 'fixtures/first/nested', ignore: '**' },
503+
504+
{ pattern: '../{first,second}', cwd: 'fixtures/first', ignore: '../first/**' },
505+
{ pattern: '../{first,second}', cwd: 'fixtures/first', ignore: '**/first/**' }
506+
]);

0 commit comments

Comments
 (0)