mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 13:35:58 +03:00
e6d0f80465
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
28 lines
595 B
Swift
28 lines
595 B
Swift
import Foundation
|
|
|
|
@discardableResult
|
|
func run(
|
|
_ launchPath: String,
|
|
_ args: [String],
|
|
env: [String: String]? = nil,
|
|
quiet: Bool = false
|
|
) -> Int32 {
|
|
let task = Process()
|
|
task.launchPath = launchPath
|
|
task.arguments = args
|
|
|
|
if let env,
|
|
let combinedEnv = task.environment?.merging(env, uniquingKeysWith: { (_, new) in new })
|
|
{
|
|
task.environment = combinedEnv
|
|
}
|
|
|
|
if quiet {
|
|
task.standardOutput = nil
|
|
task.standardError = nil
|
|
}
|
|
|
|
task.launch()
|
|
task.waitUntilExit()
|
|
return task.terminationStatus
|
|
}
|