Skip to content

Commit ca809f0

Browse files
committed
fix: Create options if it does not exist when updating them
Previously, the file could not be read to be updated. If the file does not exist, simply serialize the options to the file.
1 parent 5d50d1a commit ca809f0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/kotlin/app/revanced/cli/command/OptionsCommand.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ internal object OptionsCommand : Runnable {
2323
@CommandLine.Option(
2424
names = ["-p", "--path"], description = ["Path to patch options JSON file"], showDefaultValue = ALWAYS
2525
)
26-
private var path: File = File("options.json")
26+
private var filePath: File = File("options.json")
2727

2828
@CommandLine.Option(
2929
names = ["-o", "--overwrite"], description = ["Overwrite existing options file"], showDefaultValue = ALWAYS
@@ -37,10 +37,10 @@ internal object OptionsCommand : Runnable {
3737
)
3838
private var update: Boolean = false
3939

40-
override fun run() = if (!path.exists() || overwrite) with(PatchBundleLoader.Jar(*patchBundles)) {
41-
if (update) setOptions(path)
40+
override fun run() = if (!filePath.exists() || overwrite) with(PatchBundleLoader.Jar(*patchBundles)) {
41+
if (update && filePath.exists()) setOptions(filePath)
4242

43-
Options.serialize(this, prettyPrint = true).let(path::writeText)
43+
Options.serialize(this, prettyPrint = true).let(filePath::writeText)
4444
}
4545
else logger.severe("Options file already exists, use --override to override it")
4646
}

0 commit comments

Comments
 (0)