Skip to content

Commit

Permalink
feat: packageRules filter on depTypes
Browse files Browse the repository at this point in the history
Needed for package managers that support more than one depType (e.g. Bundler).

Closes #3076
  • Loading branch information
rarkins committed Jan 21, 2019
1 parent b8df0f8 commit b212f8d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/util/package-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function applyPackageRules(inputConfig) {
versionScheme,
packageFile,
depType,
depTypes,
depName,
currentValue,
fromVersion,
Expand Down Expand Up @@ -71,7 +72,9 @@ function applyPackageRules(inputConfig) {
negativeMatch = negativeMatch || !isMatch;
}
if (depTypeList.length) {
const isMatch = depTypeList.includes(depType);
const isMatch =
depTypeList.includes(depType) ||
(depTypes && depTypes.some(dt => depTypeList.includes(dt)));
positiveMatch = positiveMatch || isMatch;
negativeMatch = negativeMatch || !isMatch;
}
Expand Down
17 changes: 17 additions & 0 deletions test/util/package-rules.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,23 @@ describe('applyPackageRules()', () => {
const res = applyPackageRules({ ...config, ...dep });
expect(res.x).toBe(1);
});
it('filters depTypes', () => {
const config = {
packageRules: [
{
depTypeList: ['test'],
packageNames: ['a'],
x: 1,
},
],
};
const dep = {
depTypes: ['build', 'test'],
depName: 'a',
};
const res = applyPackageRules({ ...config, ...dep });
expect(res.x).toBe(1);
});
it('filters managers with matching manager', () => {
const config = {
packageRules: [
Expand Down

0 comments on commit b212f8d

Please sign in to comment.