executePatches -> applyPatches, made logback a test dep

This commit is contained in:
Lucaskyy 2022-03-19 21:58:31 +01:00
parent 6bd4d80c47
commit f9327a2043
No known key found for this signature in database
GPG key ID: 1530BFF96D1EEB89
3 changed files with 6 additions and 7 deletions

View file

@ -16,8 +16,8 @@ dependencies {
implementation("org.ow2.asm:asm-util:9.2")
implementation("org.ow2.asm:asm-tree:9.2")
implementation("org.ow2.asm:asm-commons:9.2")
implementation("ch.qos.logback:logback-classic:1.2.11")
implementation("io.github.microutils:kotlin-logging:2.1.21")
testImplementation("ch.qos.logback:logback-classic:1.2.11") // use your own logger!
testImplementation(kotlin("test"))
}

View file

@ -2,13 +2,11 @@ package net.revanced.patcher
import net.revanced.patcher.cache.Cache
import net.revanced.patcher.patch.Patch
import net.revanced.patcher.patch.PatchResult
import net.revanced.patcher.resolver.MethodResolver
import net.revanced.patcher.signature.Signature
import net.revanced.patcher.util.Jar2ASM
import java.io.InputStream
import java.io.OutputStream
import java.util.jar.JarFile
/**
* The patcher. (docs WIP)
@ -32,7 +30,7 @@ class Patcher (
this.patches.addAll(patches)
}
fun executePatches(): Map<String, Result<Nothing?>> {
fun applyPatches(stopOnError: Boolean = false): Map<String, Result<Nothing?>> {
return buildMap {
for (patch in patches) {
val result: Result<Nothing?> = try {
@ -43,11 +41,12 @@ class Patcher (
Result.failure(e)
}
this[patch.patchName] = result
if (stopOnError && result.isFailure) break
}
}
}
fun save(output: OutputStream) {
fun saveTo(output: OutputStream) {
}
}

View file

@ -37,7 +37,7 @@ internal class PatcherTest {
}
)
val result = patcher.executePatches()
val result = patcher.applyPatches()
for ((s, r) in result) {
if (r.isFailure) {
throw Exception("Patch $s failed", r.exceptionOrNull()!!)