/
paths.ts
36 lines (33 loc) · 991 Bytes
/
paths.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import is from '@sindresorhus/is';
import { minimatch } from 'minimatch';
import type { PackageRule, PackageRuleInputConfig } from '../../config/types';
import { logger } from '../../logger';
import { Matcher } from './base';
export class PathsMatcher extends Matcher {
override matches(
{ packageFile }: PackageRuleInputConfig,
{ matchPaths }: PackageRule
): boolean | null {
if (is.undefined(matchPaths)) {
return null;
}
if (is.undefined(packageFile)) {
return false;
}
return matchPaths.some((rulePath) => {
if (minimatch(packageFile, rulePath, { dot: true })) {
return true;
}
if (packageFile.includes(rulePath)) {
logger.warn(
{
rulePath,
packageFile,
},
'Partial matches for `matchPaths` are deprecated. Please use a minimatch glob pattern or switch to `matchFiles` if you need exact matching.'
);
return true;
}
});
}
}