mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2024-11-10 01:02:22 +01:00
executePatches -> applyPatches, made logback a test dep
This commit is contained in:
parent
6bd4d80c47
commit
f9327a2043
3 changed files with 6 additions and 7 deletions
|
@ -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"))
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
||||
}
|
||||
}
|
|
@ -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()!!)
|
||||
|
|
Loading…
Reference in a new issue