Skip to content

Commit f9af597

Browse files
committed
refactor(utils): use picomatch instead of micromatch to scan a pattern
1 parent 60d2d27 commit f9af597

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/utils/pattern.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as path from 'path';
22

33
import * as globParent from 'glob-parent';
44
import * as micromatch from 'micromatch';
5+
import * as picomatch from 'picomatch';
56

67
import { MicromatchOptions, Pattern, PatternRe } from '../types';
78

@@ -104,7 +105,7 @@ export function expandBraceExpansion(pattern: Pattern): Pattern[] {
104105
}
105106

106107
export function getPatternParts(pattern: Pattern, options: MicromatchOptions): Pattern[] {
107-
const info = micromatch.scan(pattern, {
108+
const info = picomatch.scan(pattern, {
108109
...options,
109110
parts: true
110111
});

tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"pretty": true
3030
},
3131
"include": [
32+
"typings",
3233
"src/**/*"
3334
]
3435
}

typings/picomatch.d.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
declare module "picomatch" {
2+
type ScanOptions = import('micromatch').ScanOptions;
3+
type ScanInfoWithParts = import('micromatch').ScanInfoWithParts;
4+
5+
type Api = {
6+
scan(pattern: string, options: ScanOptions): ScanInfoWithParts;
7+
};
8+
9+
const api: Api;
10+
11+
export = api;
12+
}

0 commit comments

Comments
 (0)