diff --git a/src/index.ts b/src/index.ts index b4eac71..54988b7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -103,11 +103,12 @@ function processPatterns( } for (let pattern of patterns) { - pattern = normalizePattern(pattern, expandDirectories, cwd, properties, false); if (pattern.startsWith('!') && pattern[1] !== '(') { - ignorePatterns.push(pattern.slice(1)); + const newPattern = normalizePattern(pattern.slice(1), expandDirectories, cwd, properties, true); + ignorePatterns.push(newPattern); } else { - matchPatterns.push(pattern); + const newPattern = normalizePattern(pattern, expandDirectories, cwd, properties, false); + matchPatterns.push(newPattern); } } diff --git a/test/index.test.ts b/test/index.test.ts index 61e8bc3..f9ac36b 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -306,6 +306,20 @@ test('negative patterns in options', async () => { assert.deepEqual(files2.sort(), ['a/b.txt', 'b/b.txt']); }); +test('negative absolute patterns in options', async () => { + const files = await glob({ + patterns: [`${cwd.replaceAll('\\', '/')}**/*.txt`, `!${cwd.replaceAll('\\', '/')}**/b.txt`], + cwd + }); + assert.deepEqual(files.sort(), ['a/a.txt', 'b/a.txt']); + + const files2 = await glob({ + patterns: [`${cwd.replaceAll('\\', '/')}**/*.txt`, `!${cwd.replaceAll('\\', '/')}**/a.txt`], + cwd + }); + assert.deepEqual(files2.sort(), ['a/b.txt', 'b/b.txt']); +}); + test('sync version', () => { const files = globSync(['a/*.txt'], { cwd }); assert.deepEqual(files.sort(), ['a/a.txt', 'a/b.txt']);