Skip to content

Commit

Permalink
fix(matchers): pass settings to "isDynamicPattern" method
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmlnc committed Feb 9, 2020
1 parent 087c51e commit 3c33e23
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/providers/filters/deep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] {
Expand Down
3 changes: 2 additions & 1 deletion src/providers/matchers/matcher.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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', () => {
Expand Down
9 changes: 5 additions & 4 deletions src/providers/matchers/matcher.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Pattern, MicromatchOptions, PatternRe } from '../../types';
import * as utils from '../../utils';
import Settings from '../../settings';

export type PatternSegment = StaticPatternSegment | DynamicPatternSegment;

Expand Down Expand Up @@ -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();
}

Expand All @@ -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 {
Expand All @@ -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)
};
});
}
Expand Down
3 changes: 2 additions & 1 deletion src/providers/matchers/partial.spec.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down

0 comments on commit 3c33e23

Please sign in to comment.