mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 03:50:08 +02:00
👌 Cleanup
This commit is contained in:
@ -136,12 +136,16 @@ class RealShell: ShellProtocol {
|
||||
}
|
||||
|
||||
return try await withCheckedThrowingContinuation({ continuation in
|
||||
var timer: Timer?
|
||||
let timer = Timer.scheduledTimer(withTimeInterval: timeout, repeats: false) { _ in
|
||||
task.terminationHandler = nil
|
||||
task.terminate()
|
||||
return continuation.resume(throwing: ShellError.timedOut)
|
||||
}
|
||||
|
||||
task.terminationHandler = { [timer, output] process in
|
||||
process.haltListening()
|
||||
|
||||
timer?.invalidate()
|
||||
timer.invalidate()
|
||||
|
||||
if !output.err.isEmpty {
|
||||
return continuation.resume(returning: (process, .err(output.err)))
|
||||
@ -150,12 +154,6 @@ class RealShell: ShellProtocol {
|
||||
return continuation.resume(returning: (process, .out(output.out)))
|
||||
}
|
||||
|
||||
timer = Timer.scheduledTimer(withTimeInterval: timeout, repeats: false) { _ in
|
||||
task.terminationHandler = nil
|
||||
task.terminate()
|
||||
return continuation.resume(throwing: ShellError.timedOut)
|
||||
}
|
||||
|
||||
task.launch()
|
||||
task.waitUntilExit()
|
||||
})
|
||||
|
@ -25,8 +25,7 @@ class ServicesManager: ObservableObject {
|
||||
|
||||
let normalJson = await Shell
|
||||
.pipe("sudo \(Paths.brew) services info --all --json")
|
||||
.out
|
||||
.data(using: .utf8)!
|
||||
.out.data(using: .utf8)!
|
||||
|
||||
let normalServices = try! JSONDecoder()
|
||||
.decode([HomebrewService].self, from: normalJson)
|
||||
@ -38,9 +37,7 @@ class ServicesManager: ObservableObject {
|
||||
)
|
||||
}
|
||||
|
||||
guard let userServiceNames = Preferences.custom.services else {
|
||||
return
|
||||
}
|
||||
guard let userServiceNames = Preferences.custom.services else { return }
|
||||
|
||||
let rootJson = await Shell
|
||||
.pipe("\(Paths.brew) services info --all --json")
|
||||
|
Reference in New Issue
Block a user