From 5825e8d0b0c6916f3caf8f2a071f54e18200e5bd Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Fri, 1 Jan 2021 23:05:16 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Cleanup,=20updated=20READM?= =?UTF-8?q?E=20(#20)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- phpmon/Singletons/Paths.swift | 28 +++++++++++----------------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index eec19cc..f4c5dd2 100644 --- a/README.md +++ b/README.md @@ -75,8 +75,8 @@ This app isn't very complicated after all. In the end, this just (conveniently) PHP Monitor performs some integrity checks to ensure a good experience when using the app. You'll get a message telling you that PHP Monitor won't work correctly in the following scenarios: -- The PHP binary is not located in `/usr/local/bin/php` -- PHP is missing in `/usr/local/opt` +- The PHP binary is not located in `/usr/local/bin/php` (or `/opt/homebrew/bin/php`) +- PHP is missing in `/usr/local/opt` (or `/opt/homebrew/opt`) - Laravel Valet is missing in `/usr/local/bin/valet` - Brew has not been added to sudoers in `/private/etc/sudoers.d/brew` - Valet has not been added to sudoers in `/private/etc/sudoers.d/valet` diff --git a/phpmon/Singletons/Paths.swift b/phpmon/Singletons/Paths.swift index d1d5765..ee3295b 100644 --- a/phpmon/Singletons/Paths.swift +++ b/phpmon/Singletons/Paths.swift @@ -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" } }