mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-11 13:30:07 +02:00
👌 Add runComposerUpdateShellCommand
method
This commit is contained in:
@@ -44,20 +44,28 @@ import Foundation
|
|||||||
|
|
||||||
private func performComposerUpdate() async {
|
private func performComposerUpdate() async {
|
||||||
do {
|
do {
|
||||||
|
try await runComposerUpdateShellCommand()
|
||||||
|
} catch {
|
||||||
|
composerUpdateFailed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func runComposerUpdateShellCommand() async throws {
|
||||||
let command = "\(Paths.composer!) global update"
|
let command = "\(Paths.composer!) global update"
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
self.window?.addToConsole("\(command)\n")
|
self.window?.addToConsole("\(command)\n")
|
||||||
}
|
|
||||||
|
|
||||||
let (process, _) = try await Shell.attach(
|
let (process, _) = try await Shell.attach(
|
||||||
command,
|
command,
|
||||||
didReceiveOutput: { [weak self] output in
|
didReceiveOutput: { [weak self] output in
|
||||||
|
guard let window = self?.window else { return }
|
||||||
|
|
||||||
if output.hasError {
|
if output.hasError {
|
||||||
DispatchQueue.main.async { self?.window?.addToConsole(output.err) }
|
window.addToConsole(output.err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !output.out.isEmpty {
|
if !output.out.isEmpty {
|
||||||
DispatchQueue.main.async { self?.window?.addToConsole(output.out) }
|
window.addToConsole(output.out)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
withTimeout: .minutes(5)
|
withTimeout: .minutes(5)
|
||||||
@@ -68,9 +76,6 @@ import Foundation
|
|||||||
} else {
|
} else {
|
||||||
composerUpdateFailed()
|
composerUpdateFailed()
|
||||||
}
|
}
|
||||||
} catch {
|
|
||||||
composerUpdateFailed()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func composerUpdateSucceeded() {
|
private func composerUpdateSucceeded() {
|
||||||
|
@@ -35,6 +35,7 @@ class TerminalProgressWindowController: NSWindowController, NSWindowDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func addToConsole(_ string: String) {
|
public func addToConsole(_ string: String) {
|
||||||
|
DispatchQueue.main.async {
|
||||||
guard let textView = self.progressView?.textView else {
|
guard let textView = self.progressView?.textView else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -42,6 +43,7 @@ class TerminalProgressWindowController: NSWindowController, NSWindowDelegate {
|
|||||||
textView.string += string
|
textView.string += string
|
||||||
textView.scrollToEndOfDocument(nil)
|
textView.scrollToEndOfDocument(nil)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func setType(info: Bool = true) {
|
public func setType(info: Bool = true) {
|
||||||
guard let imageView = self.progressView?.imageViewType else {
|
guard let imageView = self.progressView?.imageViewType else {
|
||||||
|
Reference in New Issue
Block a user