mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-08 04:20:07 +02:00
🐛 Fix issue with php
install now showing up
This commit is contained in:
@ -14,15 +14,26 @@ class Actions {
|
|||||||
public static func detectPhpVersions() -> [String] {
|
public static func detectPhpVersions() -> [String] {
|
||||||
let files = Shell.user.pipe("ls /usr/local/opt | grep php@")
|
let files = Shell.user.pipe("ls /usr/local/opt | grep php@")
|
||||||
var versions = files.components(separatedBy: "\n")
|
var versions = files.components(separatedBy: "\n")
|
||||||
|
|
||||||
// Remove all empty strings
|
// Remove all empty strings
|
||||||
versions.removeAll { (string) -> Bool in
|
versions.removeAll { (string) -> Bool in
|
||||||
return (string == "")
|
return (string == "")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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])
|
versionsOnly.append(string.components(separatedBy: "php@")[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure the aliased version is detected
|
||||||
|
// The user may have `php` installed, but not e.g. `php@8.0`
|
||||||
|
// We should also detect that as a version that is installed
|
||||||
|
let phpAlias = App.shared.brewPhpVersion
|
||||||
|
if (!versionsOnly.contains(phpAlias)) {
|
||||||
|
versionsOnly.append(phpAlias);
|
||||||
|
}
|
||||||
|
|
||||||
return versionsOnly
|
return versionsOnly
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user