From ac27f7cf59540f93ee9f05a50755e884a646d835 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Fri, 8 Oct 2021 11:40:05 +0200 Subject: [PATCH] system() fixed virtual on WSL2 --- CHANGELOG.md | 1 + docs/history.html | 7 ++++++- docs/index.html | 2 +- lib/system.js | 4 ++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 850f872..8a6e2ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,6 +80,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 5.9.6 | 2021-10-08 | `system()` fixed virtual on WSL2 | | 5.9.5 | 2021-10-08 | `battery()` fixed isCharging (windows) | | 5.9.4 | 2021-09-23 | `processes()` fixed memVsz, Memrss (macOS M1) | | 5.9.3 | 2021-09-17 | `cpuTemperature()` improved tdie detection (linus) | diff --git a/docs/history.html b/docs/history.html index 5d7241e..6d5c509 100644 --- a/docs/history.html +++ b/docs/history.html @@ -57,10 +57,15 @@ + + 5.9.6 + 2021-10-08 + system() fixed virtual on WSL2 + 5.9.5 2021-10-08 - battery() fix isCharging (windows) + battery() fixed isCharging (windows) 5.9.4 diff --git a/docs/index.html b/docs/index.html index ef913e8..4ffe545 100644 --- a/docs/index.html +++ b/docs/index.html @@ -170,7 +170,7 @@
systeminformation
 
-
New Version: 5.9.5
+
New Version: 5.9.6
diff --git a/lib/system.js b/lib/system.js index a510450..daa6b4c 100644 --- a/lib/system.js +++ b/lib/system.js @@ -122,10 +122,10 @@ function system(callback) { util.noop(); } } - if (!result.virtual && util.linuxVersion().toLowerCase().indexOf('microsoft') >= 0) { + if (!result.virtual && (util.linuxVersion().toLowerCase().indexOf('microsoft') >= 0 || os.release().toLowerCase().indexOf('microsoft') >= 0 || os.release().toLowerCase().endsWith('wsl2'))) { let versionStr = util.linuxVersion().toLowerCase(); versionStr = versionStr.split('-')[0].replace('#', ''); - const version = parseInt(versionStr, 10) || null; + const version = os.release().toLowerCase().endsWith('wsl2') ? 'WSL2' : parseInt(versionStr, 10) || null; result.virtual = true; result.manufacturer = 'Microsoft'; result.model = 'WSL';