systeminformation 5.22.1 → 5.22.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/system.js +40 -6
  2. package/package.json +1 -1
package/lib/system.js CHANGED
@@ -215,12 +215,14 @@ function system(callback) {
215
215
  exec('ioreg -c IOPlatformExpertDevice -d 2', function (error, stdout) {
216
216
  if (!error) {
217
217
  let lines = stdout.toString().replace(/[<>"]/g, '').split('\n');
218
+ const model = splitByNumber(util.getValue(lines, 'model', '=', true));
219
+ const version = util.getValue(lines, 'version', '=', true);
218
220
  result.manufacturer = util.getValue(lines, 'manufacturer', '=', true);
219
- result.model = util.getValue(lines, 'model', '=', true, true);
220
- result.version = util.getValue(lines, 'version', '=', true);
221
+ result.model = version ? util.getValue(lines, 'model', '=', true) : model[0];
222
+ result.version = version || model[1];
221
223
  result.serial = util.getValue(lines, 'ioplatformserialnumber', '=', true);
222
224
  result.uuid = util.getValue(lines, 'ioplatformuuid', '=', true).toLowerCase();
223
- result.sku = util.getValue(lines, 'board-id', '=', true);
225
+ result.sku = util.getValue(lines, 'board-id', '=', true) || util.getValue(lines, 'target-sub-type', '=', true);
224
226
  }
225
227
  if (callback) { callback(result); }
226
228
  resolve(result);
@@ -602,6 +604,33 @@ function baseboard(callback) {
602
604
 
603
605
  exports.baseboard = baseboard;
604
606
 
607
+ function macOsChassisType(model) {
608
+ model = model.toLowerCase();
609
+ if (model.startsWith('macbookair')) { return 'Notebook'; }
610
+ if (model.startsWith('macbookpro')) { return 'Laptop'; }
611
+ if (model.startsWith('macbook')) { return 'Notebook'; }
612
+ if (model.startsWith('macmini')) { return 'Desktop'; }
613
+ if (model.startsWith('imac')) { return 'Desktop'; }
614
+ if (model.startsWith('macstudio')) { return 'Desktop'; }
615
+ if (model.startsWith('macpro')) { return 'Tower'; }
616
+ return 'Other';
617
+ }
618
+
619
+ function splitByNumber(str) {
620
+ let numberStarted = false;
621
+ let num = '';
622
+ let cpart = '';
623
+ for (const c of str) {
624
+ if ((c >= '0' && c <= '9') || numberStarted) {
625
+ numberStarted = true;
626
+ num += c;
627
+ } else {
628
+ cpart += c;
629
+ }
630
+ }
631
+ return [cpart, num];
632
+ }
633
+
605
634
  function chassis(callback) {
606
635
  const chassisTypes = ['Other',
607
636
  'Unknown',
@@ -680,11 +709,16 @@ function chassis(callback) {
680
709
  exec('ioreg -c IOPlatformExpertDevice -d 2', function (error, stdout) {
681
710
  if (!error) {
682
711
  let lines = stdout.toString().replace(/[<>"]/g, '').split('\n');
712
+ const model = util.getValue(lines, 'model', '=', true);
713
+ const modelParts = splitByNumber(model);
714
+ const version = util.getValue(lines, 'version', '=', true);
683
715
  result.manufacturer = util.getValue(lines, 'manufacturer', '=', true);
684
- result.model = util.getValue(lines, 'model', '=', true);
685
- result.version = util.getValue(lines, 'version', '=', true);
716
+ result.model = version ? util.getValue(lines, 'model', '=', true) : modelParts[0];
717
+ result.type = macOsChassisType(result.model);
718
+ result.version = version || model;
686
719
  result.serial = util.getValue(lines, 'ioplatformserialnumber', '=', true);
687
- result.assetTag = util.getValue(lines, 'board-id', '=', true);
720
+ result.assetTag = util.getValue(lines, 'board-id', '=', true) || util.getValue(lines, 'target-type', '=', true);
721
+ result.sku = util.getValue(lines, 'target-sub-type', '=', true);
688
722
  }
689
723
 
690
724
  if (callback) { callback(result); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "systeminformation",
3
- "version": "5.22.1",
3
+ "version": "5.22.2",
4
4
  "description": "Advanced, lightweight system and OS information library",
5
5
  "license": "MIT",
6
6
  "author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",