mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-11-04 22:38:43 +00:00
Simplify failedPatch count
This commit is contained in:
@@ -406,9 +406,9 @@ const api = {
|
|||||||
const patches = parsePatch(brewFromClient.patches);
|
const patches = parsePatch(brewFromClient.patches);
|
||||||
// Patch to a throwaway variable while parallelizing - we're more concerned with error/no error.
|
// Patch to a throwaway variable while parallelizing - we're more concerned with error/no error.
|
||||||
result = applyPatches(patches, encodeURI(brewFromServer.text));
|
result = applyPatches(patches, encodeURI(brewFromServer.text));
|
||||||
const failedPatches = patches.map((patch, index)=>{if(!result[1][index]){ return patch; }});
|
const failedPatchCount = result[1].filter((patchApplied)=>!patchApplied).length; //Count how many patches failed to apply
|
||||||
if(failedPatches > 0){
|
if(failedPatchCount){
|
||||||
throw (`Patch failure: ${failedPatches}/${result[1].length} did not apply`);
|
throw (`Patch failure: ${failedPatchCount}/${result[1].length} did not apply`);
|
||||||
}
|
}
|
||||||
if(decodeURI(result[0]) != brewFromClient.text){
|
if(decodeURI(result[0]) != brewFromClient.text){
|
||||||
throw ('Patches did not apply cleanly, text mismatch detected');
|
throw ('Patches did not apply cleanly, text mismatch detected');
|
||||||
|
|||||||
Reference in New Issue
Block a user