feat: refactoring project

This commit is contained in:
Carlos
2024-11-23 14:56:07 -05:00
parent f0c2a50c18
commit 1c6db5818d
2351 changed files with 39323 additions and 60326 deletions

View File

@@ -23,18 +23,28 @@ function addWatchersToSet(watchers, set) {
}
const stringToRegexp = ignored => {
if (ignored.length === 0) {
return;
}
const source = globToRegExp(ignored, { globstar: true, extended: true })
.source;
const matchingStart = source.slice(0, source.length - 1) + "(?:$|\\/)";
return matchingStart;
return source.slice(0, source.length - 1) + "(?:$|\\/)";
};
const ignoredToFunction = ignored => {
if (Array.isArray(ignored)) {
const regexp = new RegExp(ignored.map(i => stringToRegexp(i)).join("|"));
const stringRegexps = ignored.map(i => stringToRegexp(i)).filter(Boolean);
if (stringRegexps.length === 0) {
return () => false;
}
const regexp = new RegExp(stringRegexps.join("|"));
return x => regexp.test(x.replace(/\\/g, "/"));
} else if (typeof ignored === "string") {
const regexp = new RegExp(stringToRegexp(ignored));
const stringRegexp = stringToRegexp(ignored);
if (!stringRegexp) {
return () => false;
}
const regexp = new RegExp(stringRegexp);
return x => regexp.test(x.replace(/\\/g, "/"));
} else if (ignored instanceof RegExp) {
return x => ignored.test(x.replace(/\\/g, "/"));

View File

@@ -1,6 +1,6 @@
{
"name": "watchpack",
"version": "2.4.1",
"version": "2.4.2",
"description": "",
"main": "./lib/watchpack.js",
"directories": {