From cef5475f38277df7aea732f4e9a62ae7fc18d136 Mon Sep 17 00:00:00 2001 From: adryd Date: Wed, 6 Dec 2023 10:43:17 -0500 Subject: [PATCH] replace array support --- src/Patcher.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Patcher.js b/src/Patcher.js index 8bb47df..ccb0752 100644 --- a/src/Patcher.js +++ b/src/Patcher.js @@ -41,6 +41,16 @@ export default class Patcher { this.patchesToApply = new Set(); if (this.patches) { for (const patch of this.patches) { + if (patch.replace instanceof Array) { + for (const index in patch.replace) { + this.patchesToApply.add({ + name: patch.name + "_" + index, + find: patch.find, + replace: patch.replace[index], + }); + } + continue; + } this.patchesToApply.add(patch); } } @@ -287,9 +297,15 @@ export default class Patcher { return typeof value === "string" || value instanceof RegExp; }); - validateProperty(`siteConfigs[${this.name}].patches[${name}].replace`, config.replace, "replacement", true, (value) => { - return typeof value === "string" || value instanceof Function; - }); + validateProperty( + `siteConfigs[${this.name}].patches[${name}].replace`, + config.replace, + "replacement", + true, + (value) => { + return typeof value === "string" || value instanceof Function; + }, + ); } _validateModuleConfig(config) {