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

🐛 Workaround broken JSON file (AddSiteVC.swift:66)

This commit is contained in:
2022-03-20 15:56:07 +01:00
parent 2cfc5731fb
commit 22c0021ada
3 changed files with 12 additions and 7 deletions

View File

@ -73,7 +73,7 @@ class ValetSiteScanner: SiteScanner
.contentsOfDirectory(atPath: path)
return entries.forEach {
if let site = self.resolveSite(path: "\(path)/\($0))") {
if let site = self.resolveSite(path: "\(path)/\($0)") {
sites.append(site)
}
}

View File

@ -69,11 +69,14 @@ class Valet {
let file = FileManager.default.homeDirectoryForCurrentUser
.appendingPathComponent(".config/valet/config.json")
// TODO: (5.2) Fix loading of invalid JSON: do not crash the app
config = try! JSONDecoder().decode(
Valet.Configuration.self,
from: try! String(contentsOf: file, encoding: .utf8).data(using: .utf8)!
)
do {
config = try JSONDecoder().decode(
Valet.Configuration.self,
from: try String(contentsOf: file, encoding: .utf8).data(using: .utf8)!
)
} catch {
Log.err(error)
}
}
/**

View File

@ -63,7 +63,9 @@ class AddSiteVC: NSViewController, NSTextFieldDelegate {
return
}
Shell.run("cd '\(path)' && \(Paths.valet) link '\(name)'", requiresPath: true)
// Adding `valet links` is a workaround for Valet malforming the config.json file
// TODO: I will have to investigate and report this behaviour if possible
Shell.run("cd '\(path)' && \(Paths.valet) link '\(name)' && valet links", requiresPath: true)
self.dismissView(outcome: .OK)