This PR contains the work done to implement the `Update` subcommand that update the package dependencies in a *Hummingbird* project. Reviewed-on: #7 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
34 lines
861 B
Swift
34 lines
861 B
Swift
import Foundation
|
|
|
|
public struct UpdateDependenciesTask {
|
|
|
|
// MARK: Properties
|
|
|
|
private let terminalService: TerminalServicing
|
|
|
|
// MARK: Initialisers
|
|
|
|
public init(terminalService: TerminalServicing) {
|
|
self.terminalService = terminalService
|
|
}
|
|
|
|
// MARK: Functions
|
|
|
|
public func callAsFunction(at location: URL? = nil, checkOutdated: Bool = false) async throws (TerminalServiceError) {
|
|
let executableURL = URL(at: "/usr/bin/swift")
|
|
|
|
var arguments: [String] = ["package", "update"]
|
|
|
|
if let location {
|
|
arguments.append(contentsOf: ["--package-path", location.pathString])
|
|
}
|
|
|
|
if checkOutdated {
|
|
arguments.append("--dry-run")
|
|
}
|
|
|
|
try await terminalService.run(executableURL, arguments: arguments)
|
|
}
|
|
|
|
}
|