Make codesigning throw in mac crafter
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Thu, 20 Jun 2024 06:26:12 +0000 (14:26 +0800)
committerClaudio Cambra <developer@claudiocambra.com>
Mon, 8 Jul 2024 07:41:45 +0000 (15:41 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
admin/osx/mac-crafter/Sources/Utils/Codesign.swift

index 78ea5af2e0d18dc8de14577fa648db194fa7367b..e0d5e5cbf32b60823ac5654e728f35b2f02a28de 100644 (file)
 
 import Foundation
 
+enum CodeSigningError: Error {
+    case failedToCodeSign(String)
+}
+
 func codesign(
     identity: String,
     path: String,
     options: String = "--timestamp --force --preserve-metadata=entitlements --verbose=4 --options runtime"
-) {
+) throws {
     print("Code-signing \(path)...")
     let command = "codesign -s \"\(identity)\" \(options) \(path)"
     guard shell(command) == 0 else {
-        print("Failed to code-sign \(path).")
-        exit(1)
+        throw CodeSigningError.failedToCodeSign("Failed to code-sign \(path).")
     }
 }