refactor: demodularize bepinex install

This commit is contained in:
jabuxas 2024-09-28 09:55:08 -03:00
parent 464b8ef778
commit ecb4650423
2 changed files with 27 additions and 33 deletions

View File

@ -34,6 +34,7 @@ func DownloadCache() error {
} }
func DownloadBepinex() error { func DownloadBepinex() error {
if _, err := os.Stat(GAME_PATH + "/BepInEx"); err != nil {
tmpPath := TMPDIR + "/bepinex.zip" tmpPath := TMPDIR + "/bepinex.zip"
// download only if it doesnt exist // download only if it doesnt exist
@ -63,6 +64,7 @@ func DownloadBepinex() error {
return fmt.Errorf("could not extract BepInEx: %w", err) return fmt.Errorf("could not extract BepInEx: %w", err)
} }
}
return nil return nil
} }

View File

@ -18,7 +18,7 @@ func main() {
if err := SanitizeInput(&GAME_PATH); err != nil { if err := SanitizeInput(&GAME_PATH); err != nil {
log.Fatal("GAME_PATH is not set") log.Fatal("GAME_PATH is not set")
} }
installBepinex() DownloadBepinex()
} }
func getCache() error { func getCache() error {
@ -35,11 +35,3 @@ func getCache() error {
return nil return nil
} }
func installBepinex() {
if _, err := os.Stat(GAME_PATH + "/BepInEx"); err != nil {
// install bepinex
DownloadBepinex()
}
// else bepinex already installed
}