Skip to content

Commit 032e3f5

Browse files
committedApr 10, 2021
fix: set negatedExtGlob also if it does not span the whole pattern
This way micromatch can detect that this is a negation pattern.
1 parent 4a510d7 commit 032e3f5

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed
 

‎lib/parse.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ const parse = (input, options) => {
247247
output = token.close = `)$))${extglobStar}`;
248248
}
249249

250-
if (token.prev.type === 'bos' && eos()) {
250+
if (token.prev.type === 'bos') {
251251
state.negatedExtglob = true;
252252
}
253253
}

‎test/api.picomatch.js

+15
Original file line numberDiff line numberDiff line change
@@ -347,4 +347,19 @@ describe('picomatch', () => {
347347
});
348348
});
349349
});
350+
351+
describe('state', () => {
352+
describe('negatedExtglob', () => {
353+
it('should return true', () => {
354+
assert(picomatch('!(abc)', {}, true).state.negatedExtglob);
355+
assert(picomatch('!(abc)**', {}, true).state.negatedExtglob);
356+
assert(picomatch('!(abc)/**', {}, true).state.negatedExtglob);
357+
});
358+
359+
it('should return false', () => {
360+
assert(!picomatch('(!(abc))', {}, true).state.negatedExtglob);
361+
assert(!picomatch('**!(abc)', {}, true).state.negatedExtglob);
362+
});
363+
});
364+
});
350365
});

0 commit comments

Comments
 (0)
Please sign in to comment.