Created
March 10, 2020 09:53
-
-
Save lordcodes/7715f6738da66e90aeb9aaafffcd3fac to your computer and use it in GitHub Desktop.
Code for the article "Manage automation tasks using Swift Package Manager"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func runShell(_ command: String, continueOnError: Bool = false) throws { | |
do { | |
try shellOut( | |
to: command, | |
outputHandle: .standardOutput, | |
errorHandle: .standardError | |
) | |
} catch { | |
if !continueOnError { | |
throw ShellError() | |
} | |
} | |
} | |
struct ShellError: Error, CustomStringConvertible { | |
var description: String { | |
"Failed when running shell command" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment