Skip to content

Commit 191b3f7

Browse files
authored
Merge pull request #143 from Carthage/fix-warnings-on-swift-5.0-for-linux
Fix deprecation warnings on Swift 5.0 for Linux
2 parents eb47db1 + b3bb591 commit 191b3f7

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

Sources/Commandant/Command.swift

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,29 @@ extension CommandRegistry {
205205

206206
func launchTask(_ path: String, arguments: [String]) -> Int32 {
207207
let task = Process()
208-
task.launchPath = path
209208
task.arguments = arguments
210209

211-
task.launch()
210+
do {
211+
#if canImport(Darwin)
212+
if #available(macOS 10.13, *) {
213+
task.executableURL = URL(fileURLWithPath: path)
214+
try task.run()
215+
} else {
216+
task.launchPath = path
217+
task.launch()
218+
}
219+
#elseif compiler(>=5)
220+
task.executableURL = URL(fileURLWithPath: path)
221+
try task.run()
222+
#else
223+
task.launchPath = path
224+
task.launch()
225+
#endif
226+
} catch let nserror as NSError {
227+
return Int32(truncatingIfNeeded: nserror.code)
228+
} catch {
229+
return -1
230+
}
212231
task.waitUntilExit()
213232

214233
return task.terminationStatus

0 commit comments

Comments
 (0)