diff --git a/convention/src/main/kotlin/io/gitlab/jfronny/scripts/OS.kt b/convention/src/main/kotlin/io/gitlab/jfronny/scripts/OS.kt new file mode 100644 index 0000000..a3a0cb3 --- /dev/null +++ b/convention/src/main/kotlin/io/gitlab/jfronny/scripts/OS.kt @@ -0,0 +1,20 @@ +package io.gitlab.jfronny.scripts + +object OS { + val TYPE: Type = with(System.getProperty("os.name", "generic").toLowerCase()) { + when { + contains("mac") || contains("darwin") -> Type.MAC_OS + contains("win") -> Type.WINDOWS + contains("nux") -> Type.LINUX + else -> throw UnsupportedOSException() + } + } + + enum class Type(val displayName: String, val codename: String) { + WINDOWS("Windows", "windows"), + MAC_OS("OSX", "macos"), + LINUX("Linux", "linux"); + } + + class UnsupportedOSException() : RuntimeException("Unrecognized OS") +} \ No newline at end of file