Skip to content

Instantly share code, notes, and snippets.

@lordcodes
Created March 10, 2020 09:53
Show Gist options
  • Save lordcodes/7715f6738da66e90aeb9aaafffcd3fac to your computer and use it in GitHub Desktop.
Save lordcodes/7715f6738da66e90aeb9aaafffcd3fac to your computer and use it in GitHub Desktop.
Code for the article "Manage automation tasks using Swift Package Manager"
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