Skip to content

Commit

Permalink
Merge pull request #207 from moonlight-mod/cyn/patcher-nitpicks
Browse files Browse the repository at this point in the history
  • Loading branch information
Cynosphere authored Jan 29, 2025
2 parents f514cdb + 35f37d5 commit 2884478
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/core/src/patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ function patchModules(entry: WebpackJsonpEntry[1]) {
for (let i = 0; i < patches.length; i++) {
const patch = patches[i];
if (patch.prerequisite != null && !patch.prerequisite()) {
moonlight.unpatched.delete(patch);
continue;
}

Expand All @@ -136,6 +137,7 @@ function patchModules(entry: WebpackJsonpEntry[1]) {
// We ensured normal PatchReplace objects get turned into arrays on register
const replaces = patch.replace as PatchReplace[];

let isPatched = true;
for (let i = 0; i < replaces.length; i++) {
const replace = replaces[i];
let patchId = `${patch.ext}#${patch.id}`;
Expand All @@ -153,6 +155,7 @@ function patchModules(entry: WebpackJsonpEntry[1]) {

if (replaced === moduleString) {
logger.warn("Patch replacement failed", id, patch);
isPatched = false;
if (patch.hardFail) {
hardFailed = true;
break;
Expand All @@ -176,7 +179,7 @@ function patchModules(entry: WebpackJsonpEntry[1]) {
exts.add(patch.ext);
}

moonlight.unpatched.delete(patch);
if (isPatched) moonlight.unpatched.delete(patch);
if (shouldRemove) patches.splice(i--, 1);
}
}
Expand Down

0 comments on commit 2884478

Please sign in to comment.