source: trip-planner-front/node_modules/fast-glob/out/providers/matchers/partial.js@ ceaed42

Last change on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.4 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const matcher_1 = require("./matcher");
4class PartialMatcher extends matcher_1.default {
5 match(filepath) {
6 const parts = filepath.split('/');
7 const levels = parts.length;
8 const patterns = this._storage.filter((info) => !info.complete || info.segments.length > levels);
9 for (const pattern of patterns) {
10 const section = pattern.sections[0];
11 /**
12 * In this case, the pattern has a globstar and we must read all directories unconditionally,
13 * but only if the level has reached the end of the first group.
14 *
15 * fixtures/{a,b}/**
16 * ^ true/false ^ always true
17 */
18 if (!pattern.complete && levels > section.length) {
19 return true;
20 }
21 const match = parts.every((part, index) => {
22 const segment = pattern.segments[index];
23 if (segment.dynamic && segment.patternRe.test(part)) {
24 return true;
25 }
26 if (!segment.dynamic && segment.pattern === part) {
27 return true;
28 }
29 return false;
30 });
31 if (match) {
32 return true;
33 }
34 }
35 return false;
36 }
37}
38exports.default = PartialMatcher;
Note: See TracBrowser for help on using the repository browser.