feat: Allow finds to use regex (#2452)

This commit is contained in:
Nuckyz 2024-05-14 23:57:43 -03:00 committed by GitHub
parent 4da8b9aad7
commit f74da73086
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 46 additions and 13 deletions

View file

@ -257,7 +257,12 @@ function patchFactories(factories: Record<string, (module: any, exports: any, re
for (let i = 0; i < patches.length; i++) {
const patch = patches[i];
if (patch.predicate && !patch.predicate()) continue;
if (!code.includes(patch.find)) continue;
const moduleMatches = typeof patch.find === "string"
? code.includes(patch.find)
: patch.find.test(code);
if (!moduleMatches) continue;
patchedBy.add(patch.plugin);