From 7eb8e074eb42e7cb194332dc273161b33f8af4ab Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Mon, 17 Jan 2022 00:28:15 +0100 Subject: [PATCH] cpu() fix manufacturer --- CHANGELOG.md | 2 ++ docs/history.html | 5 +++++ docs/index.html | 2 +- lib/cpu.js | 23 ++++++++++++++++++++--- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2cbebe..e2bb625 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,6 +80,8 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 5.10.1 | 2022-01-17 | `cpu()` fix manufacturer | +| 5.10.0 | 2022-01-09 | basic `Android` support | | 5.9.18 | 2022-01-08 | `wifiConections()` fix empty issue (mac OS) | | 5.9.17 | 2021-12-07 | `wifiNetworks()` fix empty issue (mac OS) | | 5.9.16 | 2021-12-05 | `wifiNetworks()` adaption for Apple silicon (mac OS) | diff --git a/docs/history.html b/docs/history.html index 482c2da..b9572f3 100644 --- a/docs/history.html +++ b/docs/history.html @@ -57,6 +57,11 @@ + + 5.10.1 + 2022-01-17 + cpu() fix manufacturer + 5.10.0 2022-01-09 diff --git a/docs/index.html b/docs/index.html index 87ec048..e1553bb 100644 --- a/docs/index.html +++ b/docs/index.html @@ -170,7 +170,7 @@
systeminformation
 
-
New Version: 5.10.0
+
New Version: 5.10.1
diff --git a/lib/cpu.js b/lib/cpu.js index 670370a..4b4c17c 100644 --- a/lib/cpu.js +++ b/lib/cpu.js @@ -515,12 +515,29 @@ const socketTypes = { 63: 'LGA4677', }; +function cpuManufacturer(str) { + let result = str; + str = str.toLowerCase(); + + if (str.indexOf('intel') >= 0) { result = 'Intel'; } + if (str.indexOf('amd') >= 0) { result = 'AMD'; } + if (str.indexOf('qemu') >= 0) { result = 'QEMU'; } + if (str.indexOf('hygon') >= 0) { result = 'Hygon'; } + if (str.indexOf('centaur') >= 0) { result = 'WinChip/Via'; } + if (str.indexOf('vmware') >= 0) { result = 'VMware'; } + if (str.indexOf('Xen') >= 0) { result = 'Xen Hypervisor'; } + if (str.indexOf('tcg') >= 0) { result = 'QEMU'; } + if (str.indexOf('apple') >= 0) { result = 'Apple'; } + + return result; +} + function cpuBrandManufacturer(res) { res.brand = res.brand.replace(/\(R\)+/g, '®').replace(/\s+/g, ' ').trim(); res.brand = res.brand.replace(/\(TM\)+/g, '™').replace(/\s+/g, ' ').trim(); res.brand = res.brand.replace(/\(C\)+/g, '©').replace(/\s+/g, ' ').trim(); res.brand = res.brand.replace(/CPU+/g, '').replace(/\s+/g, ' ').trim(); - res.manufacturer = res.brand.split(' ')[0]; + res.manufacturer = cpuManufacturer(res.brand); let parts = res.brand.split(' '); parts.shift(); @@ -655,7 +672,7 @@ function getCpu() { result.speedMax = Math.round(parseFloat(util.getValue(lines, 'cpu max mhz').replace(/,/g, '.')) / 10.0) / 100; result = cpuBrandManufacturer(result); - result.vendor = util.getValue(lines, 'vendor id'); + result.vendor = cpuManufacturer(util.getValue(lines, 'vendor id')); // if (!result.vendor) { result.vendor = util.getValue(lines, 'anbieterkennung'); } result.family = util.getValue(lines, 'cpu family'); @@ -733,7 +750,7 @@ function getCpu() { result.speedMax = Math.round(parseFloat(util.getValue(lines, 'max speed').replace(/Mhz/g, '')) / 10.0) / 100; result = cpuBrandManufacturer(result); - result.vendor = util.getValue(lines, 'manufacturer'); + result.vendor = cpuManufacturer(util.getValue(lines, 'manufacturer')); let sig = util.getValue(lines, 'signature'); sig = sig.split(','); for (var i = 0; i < sig.length; i++) {