1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- 'use strict';
- Object.defineProperty(exports, '__esModule', {
- value: true
- });
- exports.default = globsToMatcher;
- function _picomatch() {
- const data = _interopRequireDefault(require('picomatch'));
- _picomatch = function () {
- return data;
- };
- return data;
- }
- var _replacePathSepForGlob = _interopRequireDefault(
- require('./replacePathSepForGlob')
- );
- function _interopRequireDefault(obj) {
- return obj && obj.__esModule ? obj : {default: obj};
- }
- const globsToMatchersMap = new Map();
- const picomatchOptions = {
- dot: true
- };
- function globsToMatcher(globs) {
- if (globs.length === 0) {
-
-
- return () => false;
- }
- const matchers = globs.map(glob => {
- if (!globsToMatchersMap.has(glob)) {
- const isMatch = (0, _picomatch().default)(glob, picomatchOptions, true);
- const matcher = {
- isMatch,
-
-
- negated: isMatch.state.negated || !!isMatch.state.negatedExtglob
- };
- globsToMatchersMap.set(glob, matcher);
- }
- return globsToMatchersMap.get(glob);
- });
- return path => {
- const replacedPath = (0, _replacePathSepForGlob.default)(path);
- let kept = undefined;
- let negatives = 0;
- for (let i = 0; i < matchers.length; i++) {
- const {isMatch, negated} = matchers[i];
- if (negated) {
- negatives++;
- }
- const matched = isMatch(replacedPath);
- if (!matched && negated) {
-
-
-
- kept = false;
- } else if (matched && !negated) {
-
-
- kept = true;
- }
- }
-
-
-
-
-
-
- return negatives === matchers.length ? kept !== false : !!kept;
- };
- }
|