update, text, response

This commit is contained in:
2025-11-02 11:09:14 +01:00
parent 14776c86b0
commit eed8a4ddcf
2794 changed files with 156786 additions and 129204 deletions

View File

@@ -11,6 +11,7 @@ export default class EntryFilter {
private _createIndexRecord;
private _onlyFileFilter;
private _onlyDirectoryFilter;
private _isSkippedByAbsoluteNegativePatterns;
private _isMatchToPatternsSet;
private _isMatchToAbsoluteNegative;
private _isMatchToPatterns;
}

View File

@@ -8,11 +8,19 @@ 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;
@@ -20,11 +28,7 @@ class EntryFilter {
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);
}
@@ -42,14 +46,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.