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

👌 Cleanup

This commit is contained in:
2022-10-18 23:44:18 +02:00
parent 1c0d9f6826
commit 658cec27c1
3 changed files with 7 additions and 3 deletions

View File

@ -126,8 +126,8 @@ class RealShell: ShellProtocol {
withTimeout timeout: TimeInterval = 5.0
) async throws -> (Process, ShellOutput) {
let task = getShellProcess(for: command)
// TODO: Make ShellOutput a struct again and add a class type for this use case only
let output = ShellOutput(out: "", err: "")
let output = ShellOutput.empty()
task.listen { incoming in
output.out += incoming; didReceiveOutput(incoming, .stdOut)

View File

@ -65,6 +65,10 @@ class ShellOutput {
self.err = err
}
static func empty() -> ShellOutput {
return ShellOutput(out: "", err: "")
}
static func out(_ out: String?, _ err: String? = nil) -> ShellOutput {
return ShellOutput(out: out ?? "", err: err ?? "")
}

View File

@ -95,7 +95,7 @@ struct BatchFakeShellOutput: Codable {
didReceiveOutput: @escaping (String, ShellStream) -> Void,
ignoreDelay: Bool = false
) async -> ShellOutput {
var output = ShellOutput(out: "", err: "")
let output = ShellOutput.empty()
for item in items {
if !ignoreDelay {