Make sure we do not download R2API, BepInEx or the same dependency multiple times

This commit is contained in:
rainyuu 2021-01-31 11:42:18 +01:00
parent 3a420c4a41
commit 268f1b2e43
2 changed files with 16 additions and 1 deletions

View File

@ -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...")

View File

@ -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
}