1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-11-06 12:50:06 +01:00

🐛 Valet specific file checks

This commit is contained in:
2023-03-24 00:30:53 +01:00
parent 0e3c9a5a68
commit b456fdc65c

View File

@@ -8,6 +8,11 @@
import Foundation import Foundation
struct FileExistenceCheck {
let condition: (() -> Bool)?
let path: String
}
class PhpConfigChecker { class PhpConfigChecker {
public static var shared = PhpConfigChecker() public static var shared = PhpConfigChecker()
@@ -17,15 +22,21 @@ class PhpConfigChecker {
public func check() { public func check() {
missing = [] missing = []
let shouldExist = [ let shouldExist: [FileExistenceCheck] = [
"php.ini", FileExistenceCheck(condition: nil, path: "php.ini"),
"php-fpm.conf", FileExistenceCheck(condition: nil, path: "php-fpm.conf"),
"php-fpm.d/valet-fpm.conf" FileExistenceCheck(condition: { Valet.installed }, path: "php-fpm.d/valet-fpm.conf")
] ]
for version in PhpEnv.shared.availablePhpVersions { for version in PhpEnv.shared.availablePhpVersions {
for file in shouldExist { for file in shouldExist {
let fullFilePath = Paths.etcPath.appending("/php/\(version)/\(file)") // Early exit in case our condition is not met
if file.condition != nil && file.condition!() == false {
continue
}
// Do the check
let fullFilePath = Paths.etcPath.appending("/php/\(version)/\(file.path)")
if !FileSystem.fileExists(fullFilePath) { if !FileSystem.fileExists(fullFilePath) {
missing.append(fullFilePath) missing.append(fullFilePath)
} }