diff --git a/Sources/XcodesKit/Environment.swift b/Sources/XcodesKit/Environment.swift index 60c5acb..cb8f3e9 100644 --- a/Sources/XcodesKit/Environment.swift +++ b/Sources/XcodesKit/Environment.swift @@ -244,6 +244,12 @@ public struct Files { return try temporalDirectory(URL) } + public var xcodeExpansionDirectory: (URL, URL) -> URL = { (try? Current.files.temporalDirectory(for: $1)) ?? $0.deletingLastPathComponent() } + + public func xcodeExpansionDirectory(archiveURL: URL, xcodeURL: URL) -> URL { + return xcodeExpansionDirectory(archiveURL, xcodeURL) + } + public var installedXcodes = XcodesKit.installedXcodes } private func installedXcodes(directory: Path) -> [InstalledXcode] { diff --git a/Sources/XcodesKit/XcodeInstaller.swift b/Sources/XcodesKit/XcodeInstaller.swift index c8ff171..77ad5d7 100644 --- a/Sources/XcodesKit/XcodeInstaller.swift +++ b/Sources/XcodesKit/XcodeInstaller.swift @@ -718,7 +718,7 @@ public final class XcodeInstaller { } func unarchiveAndMoveXIP(at source: URL, to destination: URL) -> Promise { - let xcodeExpansionDirectory = (try? Current.files.temporalDirectory(for: destination)) ?? source.deletingLastPathComponent() + let xcodeExpansionDirectory = Current.files.xcodeExpansionDirectory(archiveURL: source, xcodeURL: destination) return firstly { () -> Promise in Current.logging.log(InstallationStep.unarchiving.description) return Current.shell.unxip(source, xcodeExpansionDirectory) diff --git a/Tests/XcodesKitTests/Environment+Mock.swift b/Tests/XcodesKitTests/Environment+Mock.swift index cfd358e..92b1039 100644 --- a/Tests/XcodesKitTests/Environment+Mock.swift +++ b/Tests/XcodesKitTests/Environment+Mock.swift @@ -61,6 +61,7 @@ extension Files { createFile: { _, _, _ in return true }, createDirectory: { _, _, _ in }, temporalDirectory: { _ in return URL(fileURLWithPath: NSTemporaryDirectory()) }, + xcodeExpansionDirectory: { _, _ in return URL(fileURLWithPath: NSTemporaryDirectory()) }, installedXcodes: { _ in [] } ) }