mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-18 19:07:08 -04:00
feat: Allow finds to use regex (#2452)
This commit is contained in:
parent
4da8b9aad7
commit
f74da73086
3 changed files with 46 additions and 13 deletions
|
@ -29,14 +29,19 @@ export default function definePlugin<P extends PluginDef>(p: P & Record<string,
|
|||
export type ReplaceFn = (match: string, ...groups: string[]) => string;
|
||||
|
||||
export interface PatchReplacement {
|
||||
/** The match for the patch replacement. If you use a string it will be implicitly converted to a RegExp */
|
||||
match: string | RegExp;
|
||||
/** The replacement string or function which returns the string for the patch replacement */
|
||||
replace: string | ReplaceFn;
|
||||
/** A function which returns whether this patch replacement should be applied */
|
||||
predicate?(): boolean;
|
||||
}
|
||||
|
||||
export interface Patch {
|
||||
plugin: string;
|
||||
find: string;
|
||||
/** A string or RegExp which is only include/matched in the module code you wish to patch. Prefer only using a RegExp if a simple string test is not enough */
|
||||
find: string | RegExp;
|
||||
/** The replacement(s) for the module being patched */
|
||||
replacement: PatchReplacement | PatchReplacement[];
|
||||
/** Whether this patch should apply to multiple modules */
|
||||
all?: boolean;
|
||||
|
@ -44,6 +49,7 @@ export interface Patch {
|
|||
noWarn?: boolean;
|
||||
/** Only apply this set of replacements if all of them succeed. Use this if your replacements depend on each other */
|
||||
group?: boolean;
|
||||
/** A function which returns whether this patch should be applied */
|
||||
predicate?(): boolean;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue