From 3c33e238c774409f3174c252d706009f50d0eccf Mon Sep 17 00:00:00 2001 From: mrmlnc Date: Sun, 9 Feb 2020 13:18:22 +0300 Subject: [PATCH] fix(matchers): pass settings to "isDynamicPattern" method --- src/providers/filters/deep.ts | 2 +- src/providers/matchers/matcher.spec.ts | 3 ++- src/providers/matchers/matcher.ts | 9 +++++---- src/providers/matchers/partial.spec.ts | 3 ++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/providers/filters/deep.ts b/src/providers/filters/deep.ts index cc6c34e7..9120983d 100644 --- a/src/providers/filters/deep.ts +++ b/src/providers/filters/deep.ts @@ -14,7 +14,7 @@ export default class DeepFilter { } private _getMatcher(patterns: Pattern[]): PartialMatcher { - return new PartialMatcher(patterns, this._micromatchOptions); + return new PartialMatcher(patterns, this._settings, this._micromatchOptions); } private _getNegativePatternsRe(patterns: Pattern[]): PatternRe[] { diff --git a/src/providers/matchers/matcher.spec.ts b/src/providers/matchers/matcher.spec.ts index 52e9801c..1c2bcb9d 100644 --- a/src/providers/matchers/matcher.spec.ts +++ b/src/providers/matchers/matcher.spec.ts @@ -2,6 +2,7 @@ import * as assert from 'assert'; import * as tests from '../../tests'; import { Pattern, MicromatchOptions } from '../../types'; +import Settings from '../../settings'; import Matcher, { PatternInfo } from './matcher'; class TestMatcher extends Matcher { @@ -11,7 +12,7 @@ class TestMatcher extends Matcher { } function getMatcher(patterns: Pattern[], options: MicromatchOptions = {}): TestMatcher { - return new TestMatcher(patterns, options); + return new TestMatcher(patterns, new Settings(), options); } describe('Providers → Matchers → Matcher', () => { diff --git a/src/providers/matchers/matcher.ts b/src/providers/matchers/matcher.ts index feb5d31a..75d2d991 100644 --- a/src/providers/matchers/matcher.ts +++ b/src/providers/matchers/matcher.ts @@ -1,5 +1,6 @@ import { Pattern, MicromatchOptions, PatternRe } from '../../types'; import * as utils from '../../utils'; +import Settings from '../../settings'; export type PatternSegment = StaticPatternSegment | DynamicPatternSegment; @@ -29,7 +30,7 @@ export type PatternInfo = { export default abstract class Matcher { protected readonly _storage: PatternInfo[] = []; - constructor(private readonly _patterns: Pattern[], private readonly _options: MicromatchOptions) { + constructor(private readonly _patterns: Pattern[], private readonly _settings: Settings, private readonly _micromatchOptions: MicromatchOptions) { this._fillStorage(); } @@ -54,10 +55,10 @@ export default abstract class Matcher { } private _getPatternSegments(pattern: Pattern): PatternSegment[] { - const parts = utils.pattern.getPatternParts(pattern, this._options); + const parts = utils.pattern.getPatternParts(pattern, this._micromatchOptions); return parts.map((part) => { - const dynamic = utils.pattern.isDynamicPattern(part); + const dynamic = utils.pattern.isDynamicPattern(part, this._settings); if (!dynamic) { return { @@ -69,7 +70,7 @@ export default abstract class Matcher { return { dynamic: true, pattern: part, - patternRe: utils.pattern.makeRe(part, this._options) + patternRe: utils.pattern.makeRe(part, this._micromatchOptions) }; }); } diff --git a/src/providers/matchers/partial.spec.ts b/src/providers/matchers/partial.spec.ts index 92772702..231f1ad5 100644 --- a/src/providers/matchers/partial.spec.ts +++ b/src/providers/matchers/partial.spec.ts @@ -1,10 +1,11 @@ import * as assert from 'assert'; import { Pattern, MicromatchOptions } from '../../types'; +import Settings from '../../settings'; import Matcher from './partial'; function getMatcher(patterns: Pattern[], options: MicromatchOptions = {}): Matcher { - return new Matcher(patterns, options); + return new Matcher(patterns, new Settings(), options); } function assertMatch(patterns: Pattern[], filepath: string): void | never {