Skip to content

Commit

Permalink
Freshen generated index.js file.
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidAnson committed Jan 14, 2025
1 parent a30a754 commit 49e5884
Showing 1 changed file with 54 additions and 14 deletions.
68 changes: 54 additions & 14 deletions dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5397,23 +5397,27 @@ class EntryFilter {
this.index = new Map();
}
getFilter(positive, negative) {
const positiveRe = utils.pattern.convertPatternsToRe(positive, this._micromatchOptions);
const negativeRe = utils.pattern.convertPatternsToRe(negative, Object.assign(Object.assign({}, this._micromatchOptions), { dot: true }));
return (entry) => this._filter(entry, positiveRe, negativeRe);
const [absoluteNegative, relativeNegative] = utils.pattern.partitionAbsoluteAndRelative(negative);
const patterns = {
positive: {
all: utils.pattern.convertPatternsToRe(positive, this._micromatchOptions)
},
negative: {
absolute: utils.pattern.convertPatternsToRe(absoluteNegative, Object.assign(Object.assign({}, this._micromatchOptions), { dot: true })),
relative: utils.pattern.convertPatternsToRe(relativeNegative, Object.assign(Object.assign({}, this._micromatchOptions), { dot: true }))
}
};
return (entry) => this._filter(entry, patterns);
}
_filter(entry, positiveRe, negativeRe) {
_filter(entry, patterns) {
const filepath = utils.path.removeLeadingDotSegment(entry.path);
if (this._settings.unique && this._isDuplicateEntry(filepath)) {
return false;
}
if (this._onlyFileFilter(entry) || this._onlyDirectoryFilter(entry)) {
return false;
}
if (this._isSkippedByAbsoluteNegativePatterns(filepath, negativeRe)) {
return false;
}
const isDirectory = entry.dirent.isDirectory();
const isMatched = this._isMatchToPatterns(filepath, positiveRe, isDirectory) && !this._isMatchToPatterns(filepath, negativeRe, isDirectory);
const isMatched = this._isMatchToPatternsSet(filepath, patterns, entry.dirent.isDirectory());
if (this._settings.unique && isMatched) {
this._createIndexRecord(filepath);
}
Expand All @@ -5431,14 +5435,32 @@ class EntryFilter {
_onlyDirectoryFilter(entry) {
return this._settings.onlyDirectories && !entry.dirent.isDirectory();
}
_isSkippedByAbsoluteNegativePatterns(entryPath, patternsRe) {
if (!this._settings.absolute) {
_isMatchToPatternsSet(filepath, patterns, isDirectory) {
const isMatched = this._isMatchToPatterns(filepath, patterns.positive.all, isDirectory);
if (!isMatched) {
return false;
}
const fullpath = utils.path.makeAbsolute(this._settings.cwd, entryPath);
return utils.pattern.matchAny(fullpath, patternsRe);
const isMatchedByRelativeNegative = this._isMatchToPatterns(filepath, patterns.negative.relative, isDirectory);
if (isMatchedByRelativeNegative) {
return false;
}
const isMatchedByAbsoluteNegative = this._isMatchToAbsoluteNegative(filepath, patterns.negative.absolute, isDirectory);
if (isMatchedByAbsoluteNegative) {
return false;
}
return true;
}
_isMatchToAbsoluteNegative(filepath, patternsRe, isDirectory) {
if (patternsRe.length === 0) {
return false;
}
const fullpath = utils.path.makeAbsolute(this._settings.cwd, filepath);
return this._isMatchToPatterns(fullpath, patternsRe, isDirectory);
}
_isMatchToPatterns(filepath, patternsRe, isDirectory) {
if (patternsRe.length === 0) {
return false;
}
// Trying to match files and directories by patterns.
const isMatched = utils.pattern.matchAny(filepath, patternsRe);
// A pattern with a trailling slash can be used for directory matching.
Expand Down Expand Up @@ -6162,7 +6184,7 @@ exports.convertPosixPathToPattern = convertPosixPathToPattern;


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.removeDuplicateSlashes = exports.matchAny = exports.convertPatternsToRe = exports.makeRe = exports.getPatternParts = exports.expandBraceExpansion = exports.expandPatternsWithBraceExpansion = exports.isAffectDepthOfReadingPattern = exports.endsWithSlashGlobStar = exports.hasGlobStar = exports.getBaseDirectory = exports.isPatternRelatedToParentDirectory = exports.getPatternsOutsideCurrentDirectory = exports.getPatternsInsideCurrentDirectory = exports.getPositivePatterns = exports.getNegativePatterns = exports.isPositivePattern = exports.isNegativePattern = exports.convertToNegativePattern = exports.convertToPositivePattern = exports.isDynamicPattern = exports.isStaticPattern = void 0;
exports.isAbsolute = exports.partitionAbsoluteAndRelative = exports.removeDuplicateSlashes = exports.matchAny = exports.convertPatternsToRe = exports.makeRe = exports.getPatternParts = exports.expandBraceExpansion = exports.expandPatternsWithBraceExpansion = exports.isAffectDepthOfReadingPattern = exports.endsWithSlashGlobStar = exports.hasGlobStar = exports.getBaseDirectory = exports.isPatternRelatedToParentDirectory = exports.getPatternsOutsideCurrentDirectory = exports.getPatternsInsideCurrentDirectory = exports.getPositivePatterns = exports.getNegativePatterns = exports.isPositivePattern = exports.isNegativePattern = exports.convertToNegativePattern = exports.convertToPositivePattern = exports.isDynamicPattern = exports.isStaticPattern = void 0;
const path = __nccwpck_require__(6928);
const globParent = __nccwpck_require__(8188);
const micromatch = __nccwpck_require__(8785);
Expand Down Expand Up @@ -6348,6 +6370,24 @@ function removeDuplicateSlashes(pattern) {
return pattern.replace(DOUBLE_SLASH_RE, '/');
}
exports.removeDuplicateSlashes = removeDuplicateSlashes;
function partitionAbsoluteAndRelative(patterns) {
const absolute = [];
const relative = [];
for (const pattern of patterns) {
if (isAbsolute(pattern)) {
absolute.push(pattern);
}
else {
relative.push(pattern);
}
}
return [absolute, relative];
}
exports.partitionAbsoluteAndRelative = partitionAbsoluteAndRelative;
function isAbsolute(pattern) {
return path.isAbsolute(pattern);
}
exports.isAbsolute = isAbsolute;


/***/ }),
Expand Down

0 comments on commit 49e5884

Please sign in to comment.