Skip to content

Commit

Permalink
Add support for nonegate in scan API
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark1626 committed Sep 30, 2019
1 parent 0f0db08 commit 275c9b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ module.exports = (input, options) => {
break;
}

if (code === CHAR_EXCLAMATION_MARK && index === start) {
if (!opts.nonegate && code === CHAR_EXCLAMATION_MARK && index === start) {
negated = true;
start++;
continue;
Expand Down
11 changes: 11 additions & 0 deletions test/api.scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ describe('picomatch', () => {
assert.equal(base('path/foo/'), 'path/foo/');
assert.equal(base('path/foo/bar.js'), 'path/foo/bar.js');
});

it('should respect nonegate opts', () => {
assert.deepEqual(scan('!foo/bar/*.js', { nonegate: true }), {
input: '!foo/bar/*.js',
prefix: '',
base: '!foo/bar',
glob: '*.js',
isGlob: true,
negated: false
});
});
});

describe('.base (glob2base test patterns)', () => {
Expand Down

0 comments on commit 275c9b9

Please sign in to comment.