Skip to content

Commit

Permalink
replace array support
Browse files Browse the repository at this point in the history
  • Loading branch information
adryd325 committed Dec 6, 2023
1 parent 5db3ab9 commit cef5475
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/Patcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit cef5475

Please sign in to comment.