diff --git a/lib/versionmanager.js b/lib/versionmanager.js index 709b1a87..28ea0d44 100644 --- a/lib/versionmanager.js +++ b/lib/versionmanager.js @@ -155,7 +155,7 @@ function composeFilter(filterPattern) { } // array else if (Array.isArray(filterPattern)) { - predicate = s => filterPattern.includes(s) + predicate = s => filterPattern.some(subpattern => composeFilter(subpattern)(s)) } // raw RegExp else if (filterPattern instanceof RegExp) { diff --git a/test/filter.test.js b/test/filter.test.js index 4c0539ed..3a714f00 100644 --- a/test/filter.test.js +++ b/test/filter.test.js @@ -57,4 +57,68 @@ describe('filter', () => { upgraded.should.have.property('lodash') }) + it('filter with regex string', async () => { + const upgraded = await ncu.run({ + packageData: JSON.stringify({ + dependencies: { + lodash: '2.0.0', + 'lodash.map': '2.0.0', + 'lodash.filter': '2.0.0' + } + }), + filter: '/lodash\\..*/' + }) + upgraded.should.have.property('lodash.map') + upgraded.should.have.property('lodash.filter') + }) + + it('filter with array of strings', async () => { + const upgraded = await ncu.run({ + packageData: JSON.stringify({ + dependencies: { + lodash: '2.0.0', + 'lodash.map': '2.0.0', + 'lodash.filter': '2.0.0' + } + }), + filter: ['lodash.map', 'lodash.filter'] + }) + upgraded.should.have.property('lodash.map') + upgraded.should.have.property('lodash.filter') + }) + + it('filter with array of regex', async () => { + const upgraded = await ncu.run({ + packageData: JSON.stringify({ + dependencies: { + 'fp-and-or': '0.1.0', + lodash: '2.0.0', + 'lodash.map': '2.0.0', + 'lodash.filter': '2.0.0' + } + }), + filter: [/lodash\..*/, /fp.*/] + }) + upgraded.should.have.property('lodash.map') + upgraded.should.have.property('lodash.filter') + upgraded.should.have.property('fp-and-or') + }) + + it('filter with array of regex strings', async () => { + const upgraded = await ncu.run({ + packageData: JSON.stringify({ + dependencies: { + 'fp-and-or': '0.1.0', + lodash: '2.0.0', + 'lodash.map': '2.0.0', + 'lodash.filter': '2.0.0' + } + }), + filter: ['/lodash\\..*/', '/fp.*/'] + }) + upgraded.should.have.property('lodash.map') + upgraded.should.have.property('lodash.filter') + upgraded.should.have.property('fp-and-or') + }) + })