+++ /dev/null
-"use strict";\r
-Object.defineProperty(exports, "__esModule", { value: true });\r
-var pathUtils = require("../../utils/path");\r
-var patternUtils = require("../../utils/pattern");\r
-var DeepFilter = /** @class */ (function () {\r
- function DeepFilter(options, micromatchOptions) {\r
- this.options = options;\r
- this.micromatchOptions = micromatchOptions;\r
- }\r
- /**\r
- * Returns filter for directories.\r
- */\r
- DeepFilter.prototype.getFilter = function (positive, negative) {\r
- var _this = this;\r
- var maxPatternDepth = this.getMaxPatternDepth(positive);\r
- var negativeRe = this.getNegativePatternsRe(negative);\r
- return function (entry) { return _this.filter(entry, negativeRe, maxPatternDepth); };\r
- };\r
- /**\r
- * Returns max depth of the provided patterns.\r
- */\r
- DeepFilter.prototype.getMaxPatternDepth = function (patterns) {\r
- var globstar = patterns.some(patternUtils.hasGlobStar);\r
- return globstar ? Infinity : patternUtils.getMaxNaivePatternsDepth(patterns);\r
- };\r
- /**\r
- * Returns RegExp's for patterns that can affect the depth of reading.\r
- */\r
- DeepFilter.prototype.getNegativePatternsRe = function (patterns) {\r
- var affectDepthOfReadingPatterns = patterns.filter(patternUtils.isAffectDepthOfReadingPattern);\r
- return patternUtils.convertPatternsToRe(affectDepthOfReadingPatterns, this.micromatchOptions);\r
- };\r
- /**\r
- * Returns «true» for directory that should be read.\r
- */\r
- DeepFilter.prototype.filter = function (entry, negativeRe, maxPatternDepth) {\r
- if (this.isSkippedByDeepOption(entry.depth)) {\r
- return false;\r
- }\r
- if (this.isSkippedByMaxPatternDepth(entry.depth, maxPatternDepth)) {\r
- return false;\r
- }\r
- if (this.isSkippedSymlinkedDirectory(entry)) {\r
- return false;\r
- }\r
- if (this.isSkippedDotDirectory(entry)) {\r
- return false;\r
- }\r
- return this.isSkippedByNegativePatterns(entry, negativeRe);\r
- };\r
- /**\r
- * Returns «true» when the «deep» option is disabled or number and depth of the entry is greater that the option value.\r
- */\r
- DeepFilter.prototype.isSkippedByDeepOption = function (entryDepth) {\r
- return !this.options.deep || (typeof this.options.deep === 'number' && entryDepth >= this.options.deep);\r
- };\r
- /**\r
- * Returns «true» when depth parameter is not an Infinity and entry depth greater that the parameter value.\r
- */\r
- DeepFilter.prototype.isSkippedByMaxPatternDepth = function (entryDepth, maxPatternDepth) {\r
- return maxPatternDepth !== Infinity && entryDepth >= maxPatternDepth;\r
- };\r
- /**\r
- * Returns «true» for symlinked directory if the «followSymlinkedDirectories» option is disabled.\r
- */\r
- DeepFilter.prototype.isSkippedSymlinkedDirectory = function (entry) {\r
- return !this.options.followSymlinkedDirectories && entry.isSymbolicLink();\r
- };\r
- /**\r
- * Returns «true» for a directory whose name starts with a period if «dot» option is disabled.\r
- */\r
- DeepFilter.prototype.isSkippedDotDirectory = function (entry) {\r
- return !this.options.dot && pathUtils.isDotDirectory(entry.path);\r
- };\r
- /**\r
- * Returns «true» for a directory whose path math to any negative pattern.\r
- */\r
- DeepFilter.prototype.isSkippedByNegativePatterns = function (entry, negativeRe) {\r
- return !patternUtils.matchAny(entry.path, negativeRe);\r
- };\r
- return DeepFilter;\r
-}());\r
-exports.default = DeepFilter;\r