Skip to content

Commit

Permalink
Fix compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kemchenj committed Feb 17, 2024
1 parent 7790d60 commit 001fac1
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
10 changes: 5 additions & 5 deletions Sources/XcodesKit/Entry+.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import Foundation
import Path

extension Entry {
extension Path {
var isAppBundle: Bool {
kind == .directory &&
path.extension == "app" &&
!path.isSymlink
type == .directory &&
`extension` == "app" &&
!isSymlink
}

var infoPlist: InfoPlist? {
let infoPlistPath = path.join("Contents").join("Info.plist")
let infoPlistPath = join("Contents").join("Info.plist")
guard
let infoPlistData = try? Data(contentsOf: infoPlistPath.url),
let infoPlist = try? PropertyListDecoder().decode(InfoPlist.self, from: infoPlistData)
Expand Down
3 changes: 1 addition & 2 deletions Sources/XcodesKit/Environment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,8 @@ public struct Files {
public var contentsOfDirectory: (URL) throws -> [URL] = { try FileManager.default.contentsOfDirectory(at: $0, includingPropertiesForKeys: nil, options: []) }

public var installedXcodes: (Path) -> [InstalledXcode] = { directory in
return ((try? directory.ls()) ?? [])
return directory.ls()
.filter { $0.isAppBundle && $0.infoPlist?.bundleID == "com.apple.dt.Xcode" }
.map { $0.path }
.compactMap(InstalledXcode.init)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/XcodesKit/Path+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Foundation

extension Path {
// Get Home even if we are running as root
static let environmentHome = ProcessInfo.processInfo.environment["HOME"].flatMap(Path.init) ?? .home
static let environmentHome = ProcessInfo.processInfo.environment["HOME"].flatMap(Path.init) ?? Path(Path.home)
static let environmentApplicationSupport = environmentHome/"Library/Application Support"
static let environmentCaches = environmentHome/"Library/Caches"
public static let environmentDownloads = environmentHome/"Downloads"
Expand Down
4 changes: 2 additions & 2 deletions Sources/XcodesKit/Process.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public typealias ProcessOutput = (status: Int32, out: String, err: String)

extension Process {
@discardableResult
static func sudo(password: String? = nil, _ executable: Path, workingDirectory: URL? = nil, _ arguments: String...) -> Promise<ProcessOutput> {
static func sudo(password: String? = nil, _ executable: some Pathish, workingDirectory: URL? = nil, _ arguments: String...) -> Promise<ProcessOutput> {
var arguments = [executable.string] + arguments
if password != nil {
arguments.insert("-S", at: 0)
Expand All @@ -16,7 +16,7 @@ extension Process {
}

@discardableResult
static func run(_ executable: Path, workingDirectory: URL? = nil, input: String? = nil, _ arguments: String...) -> Promise<ProcessOutput> {
static func run(_ executable: some Pathish, workingDirectory: URL? = nil, input: String? = nil, _ arguments: String...) -> Promise<ProcessOutput> {
return run(executable.url, workingDirectory: workingDirectory, input: input, arguments)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/XcodesKit/RuntimeInstaller.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public class RuntimeInstaller {
// 1-Mount DMG and get the mounted path
let mountedUrl = try await mountDMG(dmgUrl: dmgUrl)
// 2-Get the first path under the mounted path, should be a .pkg
let pkgPath = try! Path(url: mountedUrl)!.ls().first!.path
let pkgPath = Path(url: mountedUrl)!.ls().first!
// 3-Create a caches directory (if it doesn't exist), and
// 4-Set its ownership to the current user (important because under sudo it would be owned by root)
try Path.xcodesCaches.mkdir().setCurrentUserAsOwner()
Expand Down
2 changes: 1 addition & 1 deletion Sources/XcodesKit/Version+Xcode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public extension Version {
}

/// Attempt to instatiate a `Version` using the `.xcode-version` file in the provided directory
static func fromXcodeVersionFile(inDirectory: Path = Path.cwd) -> Version? {
static func fromXcodeVersionFile(inDirectory: some Pathish = Path.cwd) -> Version? {
let xcodeVersionFilePath = inDirectory.join(".xcode-version")
guard
Current.files.fileExists(atPath: xcodeVersionFilePath.string),
Expand Down

0 comments on commit 001fac1

Please sign in to comment.