1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-07 20:10:08 +02:00

🐛 Avoid duplicates (#30)

This commit is contained in:
2021-03-31 19:38:30 +02:00
parent f7500637fe
commit 827bd182b1

View File

@ -25,7 +25,11 @@ class Actions {
// Get a list of versions only // Get a list of versions only
var versionsOnly : [String] = [] var versionsOnly : [String] = []
versions.forEach { (string) in versions.forEach { (string) in
versionsOnly.append(string.components(separatedBy: "php@")[1]) let version = string.components(separatedBy: "php@")[1]
// Only append the version if it doesn't already exist (avoid dupes)
if !versionsOnly.contains(version) {
versionsOnly.append(version)
}
} }
// Make sure the aliased version is detected // Make sure the aliased version is detected
@ -33,6 +37,7 @@ class Actions {
// We should also detect that as a version that is installed // We should also detect that as a version that is installed
let phpAlias = App.shared.brewPhpVersion let phpAlias = App.shared.brewPhpVersion
// Avoid inserting a duplicate
if (!versionsOnly.contains(phpAlias)) { if (!versionsOnly.contains(phpAlias)) {
versionsOnly.append(phpAlias); versionsOnly.append(phpAlias);
} }