From 84759d813ea6fe18a02ca61c5823c5c47bdb1942 Mon Sep 17 00:00:00 2001 From: jython234 Date: Sun, 20 May 2018 16:02:29 -0500 Subject: [PATCH] Modify OS.isWindows to check platform before version (#2407) * Modify OS.isWindows to check if OS is Windows first before checking version. Previously OS.isWindows checked if the windows version matched the one required. This worked fine, except for the fact that it would end up comparing a linux kernel version to a windows version as it didn't check if the platform was Windows in the first place before. This caused issues as it would throw an error when comparing with non-semver linux kernels (such as Fedora). Now it checks if the current platform is Windows first, and if not, immediately returns false. Resolves: #2396 * Fix formatting for OS.ts --- ts/OS.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ts/OS.ts b/ts/OS.ts index efc71bf9e..25ee963e2 100644 --- a/ts/OS.ts +++ b/ts/OS.ts @@ -5,11 +5,12 @@ import semver from 'semver'; export const isMacOS = () => process.platform === 'darwin'; export const isLinux = () => process.platform === 'linux'; export const isWindows = (minVersion?: string) => { - const isPlatformValid = process.platform === 'win32'; + if (process.platform !== 'win32') return false; + const osRelease = os.release(); const isVersionValid = is.undefined(minVersion) ? true : semver.gte(osRelease, minVersion); - return isPlatformValid && isVersionValid; + return isVersionValid; };