1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-11-09 13:10:24 +01:00

♻️ Cleanup, updated README (#20)

This commit is contained in:
2021-01-01 23:05:16 +01:00
parent 4ea11c5f59
commit 5825e8d0b0
2 changed files with 13 additions and 19 deletions

View File

@@ -9,8 +9,8 @@
import Foundation
enum HomebrewDir: String {
case opt = "/opt/homebrew/bin"
case usr = "/usr/local/bin"
case opt = "/opt/homebrew"
case usr = "/usr/local"
}
class Paths {
@@ -19,8 +19,8 @@ class Paths {
var baseDir : HomebrewDir
init() {
let optBrewFound = Shell.fileExists("\(HomebrewDir.opt.rawValue)/brew")
let usrBrewFound = Shell.fileExists("\(HomebrewDir.usr.rawValue)/brew")
let optBrewFound = Shell.fileExists("\(HomebrewDir.opt.rawValue)/bin/brew")
let usrBrewFound = Shell.fileExists("\(HomebrewDir.usr.rawValue)/bin/brew")
if (optBrewFound) {
// This is usually the case with Homebrew installed on Apple Silicon
@@ -38,6 +38,8 @@ class Paths {
print("Homebrew directory: \(self.baseDir)")
}
// - MARK: Binaries
public static func brew() -> String {
return "\(self.binPath())/brew"
}
@@ -46,26 +48,18 @@ class Paths {
return "\(self.binPath())/php"
}
// - MARK: Paths
public static func binPath() -> String {
return self.shared.baseDir.rawValue
return "\(self.shared.baseDir.rawValue)/bin"
}
public static func optPath() -> String {
switch self.shared.baseDir {
case .opt:
return "/opt/homebrew/opt"
case .usr:
return "/usr/local/opt"
}
return "\(self.shared.baseDir.rawValue)/opt"
}
public static func etcPath() -> String {
switch self.shared.baseDir {
case .opt:
return "/opt/homebrew/etc"
case .usr:
return "/usr/local/etc"
}
return "\(self.shared.baseDir.rawValue)/etc"
}
}