fix: set negatedExtGlob also if it does not span the whole pattern · micromatch/picomatch@032e3f5

2 files changed

lines changed

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

}

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

});