Skip to content

TSCUtility: add Windows to the enumeration #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Sources/TSCUtility/Platform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public enum Platform: Equatable {
case android
case darwin
case linux(LinuxFlavor)
case windows

/// Recognized flavors of linux.
public enum LinuxFlavor: Equatable {
Expand All @@ -27,6 +28,9 @@ public enum Platform: Equatable {
public static var currentPlatform = Platform._findCurrentPlatform(localFileSystem)
/// Attempt to match `uname` with recognized platforms.
public static func _findCurrentPlatform(_ fs: FileSystem) -> Platform? {
#if os(Windows)
return .windows
#else
guard let uname = try? Process.checkNonZeroExit(args: "uname").spm_chomp().lowercased() else { return nil }
switch uname {
case "darwin":
Expand All @@ -36,6 +40,7 @@ public enum Platform: Equatable {
default:
return nil
}
#endif
}

public static func _findCurrentPlatformLinux(_ fs: FileSystem) -> Platform? {
Expand Down