From 392473e431a306bedbf7de107fadd02bd398803e Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Thu, 2 Jan 2025 18:42:43 +0100 Subject: [PATCH] system() chassis type parsing improved --- CHANGELOG.md | 1 + docs/history.html | 5 +++++ docs/index.html | 2 +- lib/system.js | 16 ++++++++-------- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7219bcd..b3d6cec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -90,6 +90,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page. | Version | Date | Comment | | ------- | ---------- | --------------------------------------------------------------------------------------------------- | +| 5.24.7 | 2025-01-03 | `system()` chassis type parsing improved (macOS) | | 5.24.6 | 2025-01-02 | `cpu()` clean brand string (linux) | | 5.24.5 | 2025-01-02 | `users()` improved date parsing (macOS) | | 5.24.4 | 2025-01-02 | `__proto__` added prototypes | diff --git a/docs/history.html b/docs/history.html index 82c9cc3..cd557d2 100644 --- a/docs/history.html +++ b/docs/history.html @@ -57,6 +57,11 @@ + + 5.24.7 + 2025-01-03 + system() chassis type detection improved (macOS) + 5.24.6 2025-01-02 diff --git a/docs/index.html b/docs/index.html index 90a0477..67ce518 100644 --- a/docs/index.html +++ b/docs/index.html @@ -170,7 +170,7 @@
systeminformation
 
- 3
New Version: 5.24.6
+ 3
New Version: 5.24.7
diff --git a/lib/system.js b/lib/system.js index 9777d53..375992d 100644 --- a/lib/system.js +++ b/lib/system.js @@ -221,7 +221,7 @@ function system(callback) { // const version = util.getValue(lines, 'version', '=', true); result.manufacturer = util.getValue(lines, 'manufacturer', '=', true); result.model = model.key; - result.type = macOsChassisType(model.model); + result.type = macOsChassisType(model.version); result.version = model.version; result.serial = util.getValue(lines, 'ioplatformserialnumber', '=', true); result.uuid = util.getValue(lines, 'ioplatformuuid', '=', true).toLowerCase(); @@ -607,13 +607,13 @@ exports.baseboard = baseboard; function macOsChassisType(model) { model = model.toLowerCase(); - if (model.startsWith('macbookair')) { return 'Notebook'; } - if (model.startsWith('macbookpro')) { return 'Laptop'; } - if (model.startsWith('macbook')) { return 'Notebook'; } - if (model.startsWith('macmini')) { return 'Desktop'; } - if (model.startsWith('imac')) { return 'Desktop'; } - if (model.startsWith('macstudio')) { return 'Desktop'; } - if (model.startsWith('macpro')) { return 'Tower'; } + if (model.indexOf('macbookair') >= 0 || model.indexOf('macbook air') >= 0) { return 'Notebook'; } + if (model.indexOf('macbookpro') >= 0 || model.indexOf('macbook pro') >= 0) { return 'Notebook'; } + if (model.indexOf('macbook') >= 0) { return 'Notebook'; } + if (model.indexOf('macmini') >= 0 || model.indexOf('mac mini') >= 0) { return 'Desktop'; } + if (model.indexOf('imac') >= 0) { return 'Desktop'; } + if (model.indexOf('macstudio') >= 0 || model.indexOf('mac studio') >= 0) { return 'Desktop'; } + if (model.indexOf('macpro') >= 0 || model.indexOf('mac pro') >= 0) { return 'Tower'; } return 'Other'; }