From 268f1b2e4373ce7e9668692f7de5acab8c3a24db Mon Sep 17 00:00:00 2001 From: rainyuu Date: Sun, 31 Jan 2021 11:42:18 +0100 Subject: [PATCH] Make sure we do not download R2API, BepInEx or the same dependency multiple times --- main.go | 7 ++++++- utils/utils.go | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index e99fc8f..e149795 100644 --- a/main.go +++ b/main.go @@ -75,7 +75,12 @@ func main() { for _, m := range os.Args[2:] { newdeps := cli.InstallMod(m) for _, d := range newdeps { - dependencies = append(dependencies, d) + dependency := tools.ExposeModString(d) + if !utils.ExistsInArray(dependencies, d) { + if dependency != "bbepis-BepInExPack" && dependency != "tristanmcpherson-R2API" { + dependencies = append(dependencies, d) + } + } } } fmt.Println("> Downloading dependencies...") diff --git a/utils/utils.go b/utils/utils.go index 00adb38..416793c 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -185,3 +185,13 @@ func DownloadFile(filepath string, url string) error { _, err = io.Copy(out, resp.Body) return err } + +// ExistsInArray checks if the given string exists in a string array +func ExistsInArray(array []string, search string) bool { + for _, i := range array { + if i == search { + return true + } + } + return false +}