Skip to content

Commit

Permalink
refactor(utils): use picomatch instead of micromatch to scan a pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmlnc committed Feb 20, 2020
1 parent 60d2d27 commit f9af597
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/utils/pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as path from 'path';

import * as globParent from 'glob-parent';
import * as micromatch from 'micromatch';
import * as picomatch from 'picomatch';

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

Expand Down Expand Up @@ -104,7 +105,7 @@ export function expandBraceExpansion(pattern: Pattern): Pattern[] {
}

export function getPatternParts(pattern: Pattern, options: MicromatchOptions): Pattern[] {
const info = micromatch.scan(pattern, {
const info = picomatch.scan(pattern, {
...options,
parts: true
});
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"pretty": true
},
"include": [
"typings",
"src/**/*"
]
}
12 changes: 12 additions & 0 deletions typings/picomatch.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
declare module "picomatch" {
type ScanOptions = import('micromatch').ScanOptions;
type ScanInfoWithParts = import('micromatch').ScanInfoWithParts;

type Api = {
scan(pattern: string, options: ScanOptions): ScanInfoWithParts;
};

const api: Api;

export = api;
}

0 comments on commit f9af597

Please sign in to comment.