system() fixed virtual on WSL2

This commit is contained in:
Sebastian Hildebrandt 2021-10-08 11:40:05 +02:00
parent 9ba20d04c9
commit ac27f7cf59
4 changed files with 10 additions and 4 deletions

View File

@ -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) |

View File

@ -57,10 +57,15 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">5.9.6</th>
<td>2021-10-08</td>
<td><span class="code">system()</span> fixed virtual on WSL2</td>
</tr>
<tr>
<th scope="row">5.9.5</th>
<td>2021-10-08</td>
<td><span class="code">battery()</span> fix isCharging (windows)</td>
<td><span class="code">battery()</span> fixed isCharging (windows)</td>
</tr>
<tr>
<th scope="row">5.9.4</th>

View File

@ -170,7 +170,7 @@
<img class="logo" src="assets/logo.png">
<div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span>&nbsp;</div>
<div class="version">New Version: <span id="version">5.9.5</span></div>
<div class="version">New Version: <span id="version">5.9.6</span></div>
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
</div>
<div class="down">

View File

@ -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';