Skip to content
Snippets Groups Projects
Unverified Commit a9c37258 authored by Sebastian Poxhofer's avatar Sebastian Poxhofer Committed by GitHub
Browse files

fix(packageRules/package-patterns): consider depName for exclude (#27046)

parent c479b213
No related branches found
No related tags found
No related merge requests found
...@@ -42,4 +42,19 @@ describe('util/package-rules/package-patterns', () => { ...@@ -42,4 +42,19 @@ describe('util/package-rules/package-patterns', () => {
expect(result).toBeTrue(); expect(result).toBeTrue();
}); });
}); });
describe('exclude', () => {
it('should exclude packageName', () => {
const result = packageNameMatcher.excludes(
{
depName: 'abc',
packageName: 'def',
},
{
excludePackagePatterns: ['def'],
},
);
expect(result).toBeTrue();
});
});
}); });
...@@ -50,9 +50,10 @@ export class PackagePatternsMatcher extends Matcher { ...@@ -50,9 +50,10 @@ export class PackagePatternsMatcher extends Matcher {
} }
override excludes( override excludes(
{ depName }: PackageRuleInputConfig, { depName, packageName }: PackageRuleInputConfig,
{ excludePackagePatterns }: PackageRule, packageRule: PackageRule,
): boolean | null { ): boolean | null {
const { excludePackagePatterns } = packageRule;
// ignore lockFileMaintenance for backwards compatibility // ignore lockFileMaintenance for backwards compatibility
if (is.undefined(excludePackagePatterns)) { if (is.undefined(excludePackagePatterns)) {
return null; return null;
...@@ -61,15 +62,22 @@ export class PackagePatternsMatcher extends Matcher { ...@@ -61,15 +62,22 @@ export class PackagePatternsMatcher extends Matcher {
return false; return false;
} }
let isMatch = false; if (
for (const pattern of excludePackagePatterns) { is.string(packageName) &&
const packageRegex = regEx(massagePattern(pattern)); matchPatternsAgainstName(excludePackagePatterns, packageName)
if (packageRegex.test(depName)) { ) {
logger.trace(`${depName} matches against ${String(packageRegex)}`); return true;
isMatch = true; }
}
if (matchPatternsAgainstName(excludePackagePatterns, depName)) {
logger.once.info(
{ packageRule, packageName, depName },
'Use excludeDepPatterns instead of excludePackagePatterns',
);
return true;
} }
return isMatch;
return false;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment