Skip to content

Commit 4016efa

Browse files
committed
composeFilter: support arrays of any of the supported top level types. Fixes #847.
1 parent 26e0162 commit 4016efa

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

lib/versionmanager.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function composeFilter(filterPattern) {
155155
}
156156
// array
157157
else if (Array.isArray(filterPattern)) {
158-
predicate = s => filterPattern.includes(s)
158+
predicate = s => filterPattern.some(subpattern => composeFilter(subpattern)(s))
159159
}
160160
// raw RegExp
161161
else if (filterPattern instanceof RegExp) {

test/filter.test.js

+64
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,68 @@ describe('filter', () => {
5757
upgraded.should.have.property('lodash')
5858
})
5959

60+
it('filter with regex string', async () => {
61+
const upgraded = await ncu.run({
62+
packageData: JSON.stringify({
63+
dependencies: {
64+
lodash: '2.0.0',
65+
'lodash.map': '2.0.0',
66+
'lodash.filter': '2.0.0'
67+
}
68+
}),
69+
filter: '/lodash\\..*/'
70+
})
71+
upgraded.should.have.property('lodash.map')
72+
upgraded.should.have.property('lodash.filter')
73+
})
74+
75+
it('filter with array of strings', async () => {
76+
const upgraded = await ncu.run({
77+
packageData: JSON.stringify({
78+
dependencies: {
79+
lodash: '2.0.0',
80+
'lodash.map': '2.0.0',
81+
'lodash.filter': '2.0.0'
82+
}
83+
}),
84+
filter: ['lodash.map', 'lodash.filter']
85+
})
86+
upgraded.should.have.property('lodash.map')
87+
upgraded.should.have.property('lodash.filter')
88+
})
89+
90+
it('filter with array of regex', async () => {
91+
const upgraded = await ncu.run({
92+
packageData: JSON.stringify({
93+
dependencies: {
94+
'fp-and-or': '0.1.0',
95+
lodash: '2.0.0',
96+
'lodash.map': '2.0.0',
97+
'lodash.filter': '2.0.0'
98+
}
99+
}),
100+
filter: [/lodash\..*/, /fp.*/]
101+
})
102+
upgraded.should.have.property('lodash.map')
103+
upgraded.should.have.property('lodash.filter')
104+
upgraded.should.have.property('fp-and-or')
105+
})
106+
107+
it('filter with array of regex strings', async () => {
108+
const upgraded = await ncu.run({
109+
packageData: JSON.stringify({
110+
dependencies: {
111+
'fp-and-or': '0.1.0',
112+
lodash: '2.0.0',
113+
'lodash.map': '2.0.0',
114+
'lodash.filter': '2.0.0'
115+
}
116+
}),
117+
filter: ['/lodash\\..*/', '/fp.*/']
118+
})
119+
upgraded.should.have.property('lodash.map')
120+
upgraded.should.have.property('lodash.filter')
121+
upgraded.should.have.property('fp-and-or')
122+
})
123+
60124
})

0 commit comments

Comments
 (0)