Start working on mac builder script
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Wed, 19 Jun 2024 09:46:59 +0000 (17:46 +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/craft-client.swift [new file with mode: 0644]

diff --git a/admin/osx/craft-client.swift b/admin/osx/craft-client.swift
new file mode 100644 (file)
index 0000000..43667a7
--- /dev/null
@@ -0,0 +1,28 @@
+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
+}