feat: Begins update for more modern swift-dependencies implementation.

This commit is contained in:
2024-12-20 12:54:10 -05:00
parent 1885a90f62
commit 847ddbc7b5
19 changed files with 439 additions and 130 deletions

View File

@@ -0,0 +1,23 @@
import Foundation
// swiftlint:disable force_try
/// Helper to create a temporary directory for running tests in.
///
/// The temporary directory will be removed after the operation has ran.
///
/// - Parameters:
/// - operation: The operation to run with the temporary directory.
public func withTemporaryDirectory(
_ operation: (URL) throws -> Void
) rethrows {
let tempUrl = FileManager.default
.temporaryDirectory
.appendingPathComponent(UUID().uuidString)
try! FileManager.default.createDirectory(at: tempUrl, withIntermediateDirectories: false)
try operation(tempUrl)
try! FileManager.default.removeItem(at: tempUrl)
}
// swiftlint:enable force_try