Skip to content

Use Subprocess for process management #410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ let package = Package(
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.7.2"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.8.2"),
.package(url: "https://github.com/apple/swift-system", from: "1.4.2"),
.package(url: "https://github.com/swiftlang/swift-subprocess", revision: "afc1f734feb29c3a1ebbd97cc1fe943f8e5d80e5"),
// This dependency provides the correct version of the formatter so that you can run `swift run swiftformat Package.swift Plugins/ Sources/ Tests/`
.package(url: "https://github.com/nicklockwood/SwiftFormat", exact: "0.49.18"),
],
Expand Down Expand Up @@ -67,6 +68,7 @@ let package = Package(
.product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
.product(name: "OpenAPIAsyncHTTPClient", package: "swift-openapi-async-http-client"),
.product(name: "SystemPackage", package: "swift-system"),
.product(name: "Subprocess", package: "swift-subprocess"),
],
swiftSettings: swiftSettings,
plugins: ["GenerateCommandModels"]
Expand Down
6 changes: 3 additions & 3 deletions Sources/LinuxPlatform/Linux.swift
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public struct Linux: Platform {
}

if requireSignatureValidation {
guard (try? self.runProgram("gpg", "--version", quiet: true)) != nil else {
guard (try? await self.runProgram("gpg", "--version", quiet: true)) != nil else {
var msg = "gpg is not installed. "
if let manager {
msg += """
Expand Down Expand Up @@ -321,7 +321,7 @@ public struct Linux: Platform {
}
return false
case "yum":
try self.runProgram("yum", "list", "installed", package, quiet: true)
try await self.runProgram("yum", "list", "installed", package, quiet: true)
return true
default:
return true
Expand Down Expand Up @@ -382,7 +382,7 @@ public struct Linux: Platform {
tmpDir / String(name)
}

try self.runProgram((tmpDir / "swiftly").string, "init")
try await self.runProgram((tmpDir / "swiftly").string, "init")
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/MacOSPlatform/MacOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public struct MacOS: Platform {
try await sys.tar(.directory(installDir)).extract(.verbose, .archive(payload)).run(self, quiet: false)
}

try self.runProgram((userHomeDir / ".swiftly/bin/swiftly").string, "init")
try await self.runProgram((userHomeDir / ".swiftly/bin/swiftly").string, "init")
}

public func uninstall(_ ctx: SwiftlyCoreContext, _ toolchain: ToolchainVersion, verbose: Bool)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftlyCore/ModeledCommandLine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ extension Runnable {
newEnv = newValue
}

try p.runProgram([executable] + args, quiet: quiet, env: newEnv)
try await p.runProgram([executable] + args, quiet: quiet, env: newEnv)
}
}

Expand Down
Loading