systeminformation 5.27.13 → 5.27.14

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 (3) hide show
  1. package/lib/filesystem.js +495 -340
  2. package/lib/util.js +250 -171
  3. package/package.json +1 -1
package/lib/util.js CHANGED
@@ -22,12 +22,12 @@ const execSync = require('child_process').execSync;
22
22
  const util = require('util');
23
23
 
24
24
  let _platform = process.platform;
25
- const _linux = (_platform === 'linux' || _platform === 'android');
26
- const _darwin = (_platform === 'darwin');
27
- const _windows = (_platform === 'win32');
28
- const _freebsd = (_platform === 'freebsd');
29
- const _openbsd = (_platform === 'openbsd');
30
- const _netbsd = (_platform === 'netbsd');
25
+ const _linux = _platform === 'linux' || _platform === 'android';
26
+ const _darwin = _platform === 'darwin';
27
+ const _windows = _platform === 'win32';
28
+ const _freebsd = _platform === 'freebsd';
29
+ const _openbsd = _platform === 'openbsd';
30
+ const _netbsd = _platform === 'netbsd';
31
31
 
32
32
  let _cores = 0;
33
33
  let wmicPath = '';
@@ -105,7 +105,9 @@ function unique(obj) {
105
105
  let stringify = {};
106
106
  for (let i = 0; i < obj.length; i++) {
107
107
  let keys = Object.keys(obj[i]);
108
- keys.sort(function (a, b) { return a - b; });
108
+ keys.sort(function (a, b) {
109
+ return a - b;
110
+ });
109
111
  let str = '';
110
112
  for (let j = 0; j < keys.length; j++) {
111
113
  str += JSON.stringify(keys[j]);
@@ -124,9 +126,10 @@ function sortByKey(array, keys) {
124
126
  let x = '';
125
127
  let y = '';
126
128
  keys.forEach(function (key) {
127
- x = x + a[key]; y = y + b[key];
129
+ x = x + a[key];
130
+ y = y + b[key];
128
131
  });
129
- return ((x < y) ? -1 : ((x > y) ? 1 : 0));
132
+ return x < y ? -1 : x > y ? 1 : 0;
130
133
  });
131
134
  }
132
135
 
@@ -148,7 +151,7 @@ function getValue(lines, property, separator, trimmed, lineMatch) {
148
151
  if (trimmed) {
149
152
  lineLower = lineLower.trim();
150
153
  }
151
- if (lineLower.startsWith(property) && (lineMatch ? (lineLower.match(property + separator)) || (lineLower.match(property + ' ' + separator)) : true)) {
154
+ if (lineLower.startsWith(property) && (lineMatch ? lineLower.match(property + separator) || lineLower.match(property + ' ' + separator) : true)) {
152
155
  const parts = trimmed ? line.trim().split(separator) : line.split(separator);
153
156
  if (parts.length >= 2) {
154
157
  parts.shift();
@@ -170,11 +173,15 @@ function decodeEscapeSequence(str, base) {
170
173
  function detectSplit(str) {
171
174
  let seperator = '';
172
175
  let part = 0;
173
- str.split('').forEach(element => {
176
+ str.split('').forEach((element) => {
174
177
  if (element >= '0' && element <= '9') {
175
- if (part === 1) { part++; }
178
+ if (part === 1) {
179
+ part++;
180
+ }
176
181
  } else {
177
- if (part === 0) { part++; }
182
+ if (part === 0) {
183
+ part++;
184
+ }
178
185
  if (part === 1) {
179
186
  seperator += element;
180
187
  }
@@ -194,7 +201,14 @@ function parseTime(t, pmDesignator) {
194
201
  if (parts[2]) {
195
202
  parts[1] += parts[2];
196
203
  }
197
- let isPM = (parts[1] && (parts[1].toLowerCase().indexOf('pm') > -1) || (parts[1].toLowerCase().indexOf('p.m.') > -1) || (parts[1].toLowerCase().indexOf('p. m.') > -1) || (parts[1].toLowerCase().indexOf('n') > -1) || (parts[1].toLowerCase().indexOf('ch') > -1) || (parts[1].toLowerCase().indexOf('ös') > -1) || (pmDesignator && parts[1].toLowerCase().indexOf(pmDesignator) > -1));
204
+ let isPM =
205
+ (parts[1] && parts[1].toLowerCase().indexOf('pm') > -1) ||
206
+ parts[1].toLowerCase().indexOf('p.m.') > -1 ||
207
+ parts[1].toLowerCase().indexOf('p. m.') > -1 ||
208
+ parts[1].toLowerCase().indexOf('n') > -1 ||
209
+ parts[1].toLowerCase().indexOf('ch') > -1 ||
210
+ parts[1].toLowerCase().indexOf('ös') > -1 ||
211
+ (pmDesignator && parts[1].toLowerCase().indexOf(pmDesignator) > -1);
198
212
  hour = parseInt(parts[0], 10);
199
213
  min = parseInt(parts[1], 10);
200
214
  hour = isPM && hour < 12 ? hour + 12 : hour;
@@ -209,7 +223,7 @@ function parseDateTime(dt, culture) {
209
223
  };
210
224
  culture = culture || {};
211
225
  let dateFormat = (culture.dateFormat || '').toLowerCase();
212
- let pmDesignator = (culture.pmDesignator || '');
226
+ let pmDesignator = culture.pmDesignator || '';
213
227
 
214
228
  const parts = dt.split(' ');
215
229
  if (parts[0]) {
@@ -221,7 +235,7 @@ function parseDateTime(dt, culture) {
221
235
  // Dateformat: yyyy/mm/dd
222
236
  result.date = dtparts[0] + '-' + ('0' + dtparts[1]).substr(-2) + '-' + ('0' + dtparts[2]).substr(-2);
223
237
  } else if (dtparts[2].length === 2) {
224
- if ((dateFormat.indexOf('/d/') > -1 || dateFormat.indexOf('/dd/') > -1)) {
238
+ if (dateFormat.indexOf('/d/') > -1 || dateFormat.indexOf('/dd/') > -1) {
225
239
  // Dateformat: mm/dd/yy
226
240
  result.date = '20' + dtparts[2] + '-' + ('0' + dtparts[1]).substr(-2) + '-' + ('0' + dtparts[0]).substr(-2);
227
241
  } else {
@@ -230,7 +244,13 @@ function parseDateTime(dt, culture) {
230
244
  }
231
245
  } else {
232
246
  // Dateformat: mm/dd/yyyy or dd/mm/yyyy
233
- const isEN = ((dt.toLowerCase().indexOf('pm') > -1) || (dt.toLowerCase().indexOf('p.m.') > -1) || (dt.toLowerCase().indexOf('p. m.') > -1) || (dt.toLowerCase().indexOf('am') > -1) || (dt.toLowerCase().indexOf('a.m.') > -1) || (dt.toLowerCase().indexOf('a. m.') > -1));
247
+ const isEN =
248
+ dt.toLowerCase().indexOf('pm') > -1 ||
249
+ dt.toLowerCase().indexOf('p.m.') > -1 ||
250
+ dt.toLowerCase().indexOf('p. m.') > -1 ||
251
+ dt.toLowerCase().indexOf('am') > -1 ||
252
+ dt.toLowerCase().indexOf('a.m.') > -1 ||
253
+ dt.toLowerCase().indexOf('a. m.') > -1;
234
254
  if ((isEN || dateFormat.indexOf('/d/') > -1 || dateFormat.indexOf('/dd/') > -1) && dateFormat.indexOf('dd/') !== 0) {
235
255
  // Dateformat: mm/dd/yyyy
236
256
  result.date = dtparts[2] + '-' + ('0' + dtparts[0]).substr(-2) + '-' + ('0' + dtparts[1]).substr(-2);
@@ -270,7 +290,7 @@ function parseDateTime(dt, culture) {
270
290
  }
271
291
 
272
292
  function parseHead(head, rights) {
273
- let space = (rights > 0);
293
+ let space = rights > 0;
274
294
  let count = 1;
275
295
  let from = 0;
276
296
  let to = 0;
@@ -366,7 +386,7 @@ function wmic(command) {
366
386
  return new Promise((resolve) => {
367
387
  process.nextTick(() => {
368
388
  try {
369
- powerShell(getWmic() + ' ' + command).then(stdout => {
389
+ powerShell(getWmic() + ' ' + command).then((stdout) => {
370
390
  resolve(stdout, '');
371
391
  });
372
392
  } catch (e) {
@@ -435,7 +455,9 @@ function powerShellStart() {
435
455
  powerShellProceedResults(_psResult + _psError);
436
456
  });
437
457
  _psChild.on('close', function () {
438
- if (_psChild) { _psChild.kill(); }
458
+ if (_psChild) {
459
+ _psChild.kill();
460
+ }
439
461
  });
440
462
  }
441
463
  }
@@ -449,13 +471,14 @@ function powerShellRelease() {
449
471
  _psPersistent = false;
450
472
  }
451
473
  } catch (e) {
452
- if (_psChild) { _psChild.kill(); }
474
+ if (_psChild) {
475
+ _psChild.kill();
476
+ }
453
477
  }
454
478
  _psChild = null;
455
479
  }
456
480
 
457
481
  function powerShell(cmd) {
458
-
459
482
  /// const pattern = [
460
483
  /// '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
461
484
  /// '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))'
@@ -483,7 +506,6 @@ function powerShell(cmd) {
483
506
  }
484
507
  });
485
508
  });
486
-
487
509
  } else {
488
510
  let result = '';
489
511
 
@@ -640,17 +662,7 @@ function smartMonToolsInstalled() {
640
662
  // https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#hardware-revision-codes
641
663
 
642
664
  function isRaspberry(cpuinfo) {
643
- const PI_MODEL_NO = [
644
- 'BCM2708',
645
- 'BCM2709',
646
- 'BCM2710',
647
- 'BCM2711',
648
- 'BCM2712',
649
- 'BCM2835',
650
- 'BCM2836',
651
- 'BCM2837',
652
- 'BCM2837B0'
653
- ];
665
+ const PI_MODEL_NO = ['BCM2708', 'BCM2709', 'BCM2710', 'BCM2711', 'BCM2712', 'BCM2835', 'BCM2836', 'BCM2837', 'BCM2837B0'];
654
666
  if (_rpi_cpuinfo !== null) {
655
667
  cpuinfo = _rpi_cpuinfo;
656
668
  } else if (cpuinfo === undefined) {
@@ -664,7 +676,7 @@ function isRaspberry(cpuinfo) {
664
676
 
665
677
  const hardware = getValue(cpuinfo, 'hardware');
666
678
  const model = getValue(cpuinfo, 'model');
667
- return ((hardware && PI_MODEL_NO.indexOf(hardware) > -1) || (model && model.indexOf('Raspberry Pi') > -1));
679
+ return (hardware && PI_MODEL_NO.indexOf(hardware) > -1) || (model && model.indexOf('Raspberry Pi') > -1);
668
680
  }
669
681
 
670
682
  function isRaspbian() {
@@ -675,7 +687,7 @@ function isRaspbian() {
675
687
  return false;
676
688
  }
677
689
  const id = getValue(osrelease, 'id', '=');
678
- return (id && id.indexOf('raspbian') > -1);
690
+ return id && id.indexOf('raspbian') > -1;
679
691
  }
680
692
 
681
693
  function execWin(cmd, opts, callback) {
@@ -693,7 +705,7 @@ function darwinXcodeExists() {
693
705
  const cmdLineToolsExists = fs.existsSync('/Library/Developer/CommandLineTools/usr/bin/');
694
706
  const xcodeAppExists = fs.existsSync('/Applications/Xcode.app/Contents/Developer/Tools');
695
707
  const xcodeExists = fs.existsSync('/Library/Developer/Xcode/');
696
- return (cmdLineToolsExists || xcodeExists || xcodeAppExists);
708
+ return cmdLineToolsExists || xcodeExists || xcodeAppExists;
697
709
  }
698
710
 
699
711
  function nanoSeconds() {
@@ -707,7 +719,7 @@ function nanoSeconds() {
707
719
  function countUniqueLines(lines, startingWith) {
708
720
  startingWith = startingWith || '';
709
721
  const uniqueLines = [];
710
- lines.forEach(line => {
722
+ lines.forEach((line) => {
711
723
  if (line.startsWith(startingWith)) {
712
724
  if (uniqueLines.indexOf(line) === -1) {
713
725
  uniqueLines.push(line);
@@ -720,7 +732,7 @@ function countUniqueLines(lines, startingWith) {
720
732
  function countLines(lines, startingWith) {
721
733
  startingWith = startingWith || '';
722
734
  const uniqueLines = [];
723
- lines.forEach(line => {
735
+ lines.forEach((line) => {
724
736
  if (line.startsWith(startingWith)) {
725
737
  uniqueLines.push(line);
726
738
  }
@@ -729,40 +741,46 @@ function countLines(lines, startingWith) {
729
741
  }
730
742
 
731
743
  function sanitizeShellString(str, strict) {
732
- if (typeof strict === 'undefined') { strict = false; }
744
+ if (typeof strict === 'undefined') {
745
+ strict = false;
746
+ }
733
747
  const s = str || '';
734
748
  let result = '';
735
749
  const l = mathMin(s.length, 2000);
736
750
  for (let i = 0; i <= l; i++) {
737
- if (!(s[i] === undefined ||
738
- s[i] === '>' ||
739
- s[i] === '<' ||
740
- s[i] === '*' ||
741
- s[i] === '?' ||
742
- s[i] === '[' ||
743
- s[i] === ']' ||
744
- s[i] === '|' ||
745
- s[i] === '˚' ||
746
- s[i] === '$' ||
747
- s[i] === ';' ||
748
- s[i] === '&' ||
749
- s[i] === ']' ||
750
- s[i] === '#' ||
751
- s[i] === '\\' ||
752
- s[i] === '\t' ||
753
- s[i] === '\n' ||
754
- s[i] === '\r' ||
755
- s[i] === '\'' ||
756
- s[i] === '`' ||
757
- s[i] === '"' ||
758
- s[i].length > 1 ||
759
- (strict && s[i] === '(') ||
760
- (strict && s[i] === ')') ||
761
- (strict && s[i] === '@') ||
762
- (strict && s[i] === ' ') ||
763
- (strict && s[i] == '{') ||
764
- (strict && s[i] == ';') ||
765
- (strict && s[i] == '}'))) {
751
+ if (
752
+ !(
753
+ s[i] === undefined ||
754
+ s[i] === '>' ||
755
+ s[i] === '<' ||
756
+ s[i] === '*' ||
757
+ s[i] === '?' ||
758
+ s[i] === '[' ||
759
+ s[i] === ']' ||
760
+ s[i] === '|' ||
761
+ s[i] === '˚' ||
762
+ s[i] === '$' ||
763
+ s[i] === ';' ||
764
+ s[i] === '&' ||
765
+ s[i] === ']' ||
766
+ s[i] === '#' ||
767
+ s[i] === '\\' ||
768
+ s[i] === '\t' ||
769
+ s[i] === '\n' ||
770
+ s[i] === '\r' ||
771
+ s[i] === "'" ||
772
+ s[i] === '`' ||
773
+ s[i] === '"' ||
774
+ s[i].length > 1 ||
775
+ (strict && s[i] === '(') ||
776
+ (strict && s[i] === ')') ||
777
+ (strict && s[i] === '@') ||
778
+ (strict && s[i] === ' ') ||
779
+ (strict && s[i] === '{') ||
780
+ (strict && s[i] === ';') ||
781
+ (strict && s[i] === '}')
782
+ )
783
+ ) {
766
784
  result = result + s[i];
767
785
  }
768
786
  }
@@ -785,10 +803,10 @@ function isPrototypePolluted() {
785
803
  } catch (e) {
786
804
  Object.setPrototypeOf(st, stringObj);
787
805
  }
788
- notPolluted = notPolluted || (s.length !== 62);
806
+ notPolluted = notPolluted || s.length !== 62;
789
807
  const ms = Date.now();
790
808
  if (typeof ms === 'number' && ms > 1600000000000) {
791
- const l = ms % 100 + 15;
809
+ const l = (ms % 100) + 15;
792
810
  for (let i = 0; i < l; i++) {
793
811
  const r = Math.random() * 61.99999999 + 1;
794
812
  const rs = parseInt(Math.floor(r).toString(), 10);
@@ -796,7 +814,7 @@ function isPrototypePolluted() {
796
814
  const q = Math.random() * 61.99999999 + 1;
797
815
  const qs = parseInt(Math.floor(q).toString(), 10);
798
816
  const qs2 = parseInt(q.toString().split('.')[0], 10);
799
- notPolluted = notPolluted && (r !== q);
817
+ notPolluted = notPolluted && r !== q;
800
818
  notPolluted = notPolluted && rs === rs2 && qs === qs2;
801
819
  st += s[rs - 1];
802
820
  }
@@ -826,7 +844,7 @@ function isPrototypePolluted() {
826
844
 
827
845
  // lower
828
846
  const stl = st.toLowerCase();
829
- notPolluted = notPolluted && (stl.length === l) && stl[l - 1] && !(stl[l]);
847
+ notPolluted = notPolluted && stl.length === l && stl[l - 1] && !stl[l];
830
848
  for (let i = 0; i < l; i++) {
831
849
  const s1 = st[i];
832
850
  try {
@@ -836,14 +854,14 @@ function isPrototypePolluted() {
836
854
  }
837
855
  const s2 = stl ? stl[i] : '';
838
856
  const s1l = s1.toLowerCase();
839
- notPolluted = notPolluted && s1l[0] === s2 && s1l[0] && !(s1l[1]);
857
+ notPolluted = notPolluted && s1l[0] === s2 && s1l[0] && !s1l[1];
840
858
  }
841
859
  }
842
860
  return !notPolluted;
843
861
  }
844
862
 
845
863
  function hex2bin(hex) {
846
- return ('00000000' + (parseInt(hex, 16)).toString(2)).substr(-8);
864
+ return ('00000000' + parseInt(hex, 16).toString(2)).substr(-8);
847
865
  }
848
866
 
849
867
  function getFilesInPath(source) {
@@ -854,21 +872,35 @@ function getFilesInPath(source) {
854
872
  function isDirectory(source) {
855
873
  return lstatSync(source).isDirectory();
856
874
  }
857
- function isFile(source) { return lstatSync(source).isFile(); }
875
+ function isFile(source) {
876
+ return lstatSync(source).isFile();
877
+ }
858
878
 
859
879
  function getDirectories(source) {
860
- return readdirSync(source).map(function (name) { return join(source, name); }).filter(isDirectory);
880
+ return readdirSync(source)
881
+ .map(function (name) {
882
+ return join(source, name);
883
+ })
884
+ .filter(isDirectory);
861
885
  }
862
886
  function getFiles(source) {
863
- return readdirSync(source).map(function (name) { return join(source, name); }).filter(isFile);
887
+ return readdirSync(source)
888
+ .map(function (name) {
889
+ return join(source, name);
890
+ })
891
+ .filter(isFile);
864
892
  }
865
893
 
866
894
  function getFilesRecursively(source) {
867
895
  try {
868
896
  let dirs = getDirectories(source);
869
897
  let files = dirs
870
- .map(function (dir) { return getFilesRecursively(dir); })
871
- .reduce(function (a, b) { return a.concat(b); }, []);
898
+ .map(function (dir) {
899
+ return getFilesRecursively(dir);
900
+ })
901
+ .reduce(function (a, b) {
902
+ return a.concat(b);
903
+ }, []);
872
904
  return files.concat(getFiles(source));
873
905
  } catch (e) {
874
906
  return [];
@@ -883,7 +915,6 @@ function getFilesInPath(source) {
883
915
  }
884
916
 
885
917
  function decodePiCpuinfo(lines) {
886
-
887
918
  if (_rpi_cpuinfo === null) {
888
919
  _rpi_cpuinfo = lines;
889
920
  } else if (lines === undefined) {
@@ -1014,21 +1045,8 @@ function decodePiCpuinfo(lines) {
1014
1045
  }
1015
1046
  };
1016
1047
 
1017
- const processorList = [
1018
- 'BCM2835',
1019
- 'BCM2836',
1020
- 'BCM2837',
1021
- 'BCM2711',
1022
- 'BCM2712',
1023
- ];
1024
- const manufacturerList = [
1025
- 'Sony UK',
1026
- 'Egoman',
1027
- 'Embest',
1028
- 'Sony Japan',
1029
- 'Embest',
1030
- 'Stadium'
1031
- ];
1048
+ const processorList = ['BCM2835', 'BCM2836', 'BCM2837', 'BCM2711', 'BCM2712'];
1049
+ const manufacturerList = ['Sony UK', 'Egoman', 'Embest', 'Sony Japan', 'Embest', 'Stadium'];
1032
1050
  const typeList = {
1033
1051
  '00': 'A',
1034
1052
  '01': 'B',
@@ -1044,17 +1062,17 @@ function decodePiCpuinfo(lines) {
1044
1062
  '0d': '3B+',
1045
1063
  '0e': '3A+',
1046
1064
  '0f': 'Internal use only',
1047
- '10': 'CM3+',
1048
- '11': '4B',
1049
- '12': 'Zero 2 W',
1050
- '13': '400',
1051
- '14': 'CM4',
1052
- '15': 'CM4S',
1053
- '16': 'Internal use only',
1054
- '17': '5',
1055
- '18': 'CM5',
1056
- '19': '500/500+',
1057
- '1a': 'CM5 Lite',
1065
+ 10: 'CM3+',
1066
+ 11: '4B',
1067
+ 12: 'Zero 2 W',
1068
+ 13: '400',
1069
+ 14: 'CM4',
1070
+ 15: 'CM4S',
1071
+ 16: 'Internal use only',
1072
+ 17: '5',
1073
+ 18: 'CM5',
1074
+ 19: '500/500+',
1075
+ '1a': 'CM5 Lite'
1058
1076
  };
1059
1077
 
1060
1078
  const revisionCode = getValue(lines, 'revision', ':', true);
@@ -1072,9 +1090,8 @@ function decodePiCpuinfo(lines) {
1072
1090
  manufacturer: oldRevisionCodes[revisionCode].manufacturer,
1073
1091
  processor: oldRevisionCodes[revisionCode].processor,
1074
1092
  type: oldRevisionCodes[revisionCode].type,
1075
- revision: oldRevisionCodes[revisionCode].revision,
1093
+ revision: oldRevisionCodes[revisionCode].revision
1076
1094
  };
1077
-
1078
1095
  } else {
1079
1096
  // new revision code
1080
1097
  const revision = ('00000000' + getValue(lines, 'revision', ':', true).toLowerCase()).substr(-8);
@@ -1083,7 +1100,6 @@ function decodePiCpuinfo(lines) {
1083
1100
  const processor = processorList[parseInt(revision.substr(4, 1), 10)];
1084
1101
  const typeCode = revision.substr(5, 2);
1085
1102
 
1086
-
1087
1103
  result = {
1088
1104
  model,
1089
1105
  serial,
@@ -1092,14 +1108,13 @@ function decodePiCpuinfo(lines) {
1092
1108
  manufacturer,
1093
1109
  processor,
1094
1110
  type: {}.hasOwnProperty.call(typeList, typeCode) ? typeList[typeCode] : '',
1095
- revision: '1.' + revision.substr(7, 1),
1111
+ revision: '1.' + revision.substr(7, 1)
1096
1112
  };
1097
1113
  }
1098
1114
  return result;
1099
1115
  }
1100
1116
 
1101
1117
  function getRpiGpu(cpuinfo) {
1102
-
1103
1118
  if (_rpi_cpuinfo === null && cpuinfo !== undefined) {
1104
1119
  _rpi_cpuinfo = cpuinfo;
1105
1120
  } else if (cpuinfo === undefined && _rpi_cpuinfo !== null) {
@@ -1114,8 +1129,12 @@ function getRpiGpu(cpuinfo) {
1114
1129
  }
1115
1130
 
1116
1131
  const rpi = decodePiCpuinfo(cpuinfo);
1117
- if (rpi.type === '4B' || rpi.type === 'CM4' || rpi.type === 'CM4S' || rpi.type === '400') { return 'VideoCore VI'; }
1118
- if (rpi.type === '5' || rpi.type === '500') { return 'VideoCore VII'; }
1132
+ if (rpi.type === '4B' || rpi.type === 'CM4' || rpi.type === 'CM4S' || rpi.type === '400') {
1133
+ return 'VideoCore VI';
1134
+ }
1135
+ if (rpi.type === '5' || rpi.type === '500') {
1136
+ return 'VideoCore VII';
1137
+ }
1119
1138
  return 'VideoCore IV';
1120
1139
  }
1121
1140
 
@@ -1123,9 +1142,10 @@ function promiseAll(promises) {
1123
1142
  const resolvingPromises = promises.map(function (promise) {
1124
1143
  return new Promise(function (resolve) {
1125
1144
  let payload = new Array(2);
1126
- promise.then(function (result) {
1127
- payload[0] = result;
1128
- })
1145
+ promise
1146
+ .then(function (result) {
1147
+ payload[0] = result;
1148
+ })
1129
1149
  .catch(function (error) {
1130
1150
  payload[1] = error;
1131
1151
  })
@@ -1139,23 +1159,22 @@ function promiseAll(promises) {
1139
1159
  const results = [];
1140
1160
 
1141
1161
  // Execute all wrapped Promises
1142
- return Promise.all(resolvingPromises)
1143
- .then(function (items) {
1144
- items.forEach(function (payload) {
1145
- if (payload[1]) {
1146
- errors.push(payload[1]);
1147
- results.push(null);
1148
- } else {
1149
- errors.push(null);
1150
- results.push(payload[0]);
1151
- }
1152
- });
1153
-
1154
- return {
1155
- errors: errors,
1156
- results: results
1157
- };
1162
+ return Promise.all(resolvingPromises).then(function (items) {
1163
+ items.forEach(function (payload) {
1164
+ if (payload[1]) {
1165
+ errors.push(payload[1]);
1166
+ results.push(null);
1167
+ } else {
1168
+ errors.push(null);
1169
+ results.push(payload[0]);
1170
+ }
1158
1171
  });
1172
+
1173
+ return {
1174
+ errors: errors,
1175
+ results: results
1176
+ };
1177
+ });
1159
1178
  }
1160
1179
 
1161
1180
  function promisify(nodeStyleFunction) {
@@ -1218,24 +1237,50 @@ function plistParser(xmlStr) {
1218
1237
 
1219
1238
  while (pos < len) {
1220
1239
  c = cn;
1221
- if (pos + 1 < len) { cn = xmlStr[pos + 1]; }
1240
+ if (pos + 1 < len) {
1241
+ cn = xmlStr[pos + 1];
1242
+ }
1222
1243
  if (c === '<') {
1223
1244
  inTagContent = false;
1224
- if (cn === '/') { inTagEnd = true; }
1225
- else if (metaData[depth].tagStart) {
1245
+ if (cn === '/') {
1246
+ inTagEnd = true;
1247
+ } else if (metaData[depth].tagStart) {
1226
1248
  metaData[depth].tagContent = '';
1227
- if (!metaData[depth].data) { metaData[depth].data = metaData[depth].tagStart === 'array' ? [] : {}; }
1249
+ if (!metaData[depth].data) {
1250
+ metaData[depth].data = metaData[depth].tagStart === 'array' ? [] : {};
1251
+ }
1228
1252
  depth++;
1229
1253
  metaData.push({ tagStart: '', tagEnd: '', tagContent: '', key: null, data: null });
1230
1254
  inTagStart = true;
1231
1255
  inTagContent = false;
1256
+ } else if (!inTagStart) {
1257
+ inTagStart = true;
1232
1258
  }
1233
- else if (!inTagStart) { inTagStart = true; }
1234
1259
  } else if (c === '>') {
1235
- if (metaData[depth].tagStart === 'true/') { inTagStart = false; inTagEnd = true; metaData[depth].tagStart = ''; metaData[depth].tagEnd = '/boolean'; metaData[depth].data = true; }
1236
- if (metaData[depth].tagStart === 'false/') { inTagStart = false; inTagEnd = true; metaData[depth].tagStart = ''; metaData[depth].tagEnd = '/boolean'; metaData[depth].data = false; }
1237
- if (metaData[depth].tagStart === 'array/') { inTagStart = false; inTagEnd = true; metaData[depth].tagStart = ''; metaData[depth].tagEnd = '/arrayEmpty'; metaData[depth].data = []; }
1238
- if (inTagContent) { inTagContent = false; }
1260
+ if (metaData[depth].tagStart === 'true/') {
1261
+ inTagStart = false;
1262
+ inTagEnd = true;
1263
+ metaData[depth].tagStart = '';
1264
+ metaData[depth].tagEnd = '/boolean';
1265
+ metaData[depth].data = true;
1266
+ }
1267
+ if (metaData[depth].tagStart === 'false/') {
1268
+ inTagStart = false;
1269
+ inTagEnd = true;
1270
+ metaData[depth].tagStart = '';
1271
+ metaData[depth].tagEnd = '/boolean';
1272
+ metaData[depth].data = false;
1273
+ }
1274
+ if (metaData[depth].tagStart === 'array/') {
1275
+ inTagStart = false;
1276
+ inTagEnd = true;
1277
+ metaData[depth].tagStart = '';
1278
+ metaData[depth].tagEnd = '/arrayEmpty';
1279
+ metaData[depth].data = [];
1280
+ }
1281
+ if (inTagContent) {
1282
+ inTagContent = false;
1283
+ }
1239
1284
  if (inTagStart) {
1240
1285
  inTagStart = false;
1241
1286
  inTagContent = true;
@@ -1261,18 +1306,31 @@ function plistParser(xmlStr) {
1261
1306
  metaData[depth].tagContent = '';
1262
1307
  metaData[depth].tagStart = '';
1263
1308
  metaData[depth].tagEnd = '';
1264
- }
1265
- else {
1309
+ } else {
1266
1310
  if (metaData[depth].tagEnd === '/key' && metaData[depth].tagContent) {
1267
1311
  metaData[depth].key = metaData[depth].tagContent;
1268
1312
  } else {
1269
- if (metaData[depth].tagEnd === '/real' && metaData[depth].tagContent) { metaData[depth].data = parseFloat(metaData[depth].tagContent) || 0; }
1270
- if (metaData[depth].tagEnd === '/integer' && metaData[depth].tagContent) { metaData[depth].data = parseInt(metaData[depth].tagContent) || 0; }
1271
- if (metaData[depth].tagEnd === '/string' && metaData[depth].tagContent) { metaData[depth].data = metaData[depth].tagContent || ''; }
1272
- if (metaData[depth].tagEnd === '/boolean') { metaData[depth].data = metaData[depth].tagContent || false; }
1273
- if (metaData[depth].tagEnd === '/arrayEmpty') { metaData[depth].data = metaData[depth].tagContent || []; }
1274
- if (depth > 0 && metaData[depth - 1].tagStart === 'array') { metaData[depth - 1].data.push(metaData[depth].data); }
1275
- if (depth > 0 && metaData[depth - 1].tagStart === 'dict') { metaData[depth - 1].data[metaData[depth].key] = metaData[depth].data; }
1313
+ if (metaData[depth].tagEnd === '/real' && metaData[depth].tagContent) {
1314
+ metaData[depth].data = parseFloat(metaData[depth].tagContent) || 0;
1315
+ }
1316
+ if (metaData[depth].tagEnd === '/integer' && metaData[depth].tagContent) {
1317
+ metaData[depth].data = parseInt(metaData[depth].tagContent) || 0;
1318
+ }
1319
+ if (metaData[depth].tagEnd === '/string' && metaData[depth].tagContent) {
1320
+ metaData[depth].data = metaData[depth].tagContent || '';
1321
+ }
1322
+ if (metaData[depth].tagEnd === '/boolean') {
1323
+ metaData[depth].data = metaData[depth].tagContent || false;
1324
+ }
1325
+ if (metaData[depth].tagEnd === '/arrayEmpty') {
1326
+ metaData[depth].data = metaData[depth].tagContent || [];
1327
+ }
1328
+ if (depth > 0 && metaData[depth - 1].tagStart === 'array') {
1329
+ metaData[depth - 1].data.push(metaData[depth].data);
1330
+ }
1331
+ if (depth > 0 && metaData[depth - 1].tagStart === 'dict') {
1332
+ metaData[depth - 1].data[metaData[depth].key] = metaData[depth].data;
1333
+ }
1276
1334
  }
1277
1335
  metaData[depth].tagContent = '';
1278
1336
  metaData[depth].tagStart = '';
@@ -1284,9 +1342,15 @@ function plistParser(xmlStr) {
1284
1342
  inTagContent = false;
1285
1343
  }
1286
1344
  } else {
1287
- if (inTagStart) { metaData[depth].tagStart += c; }
1288
- if (inTagEnd) { metaData[depth].tagEnd += c; }
1289
- if (inTagContent) { metaData[depth].tagContent += c; }
1345
+ if (inTagStart) {
1346
+ metaData[depth].tagStart += c;
1347
+ }
1348
+ if (inTagEnd) {
1349
+ metaData[depth].tagEnd += c;
1350
+ }
1351
+ if (inTagContent) {
1352
+ metaData[depth].tagContent += c;
1353
+ }
1290
1354
  }
1291
1355
  pos++;
1292
1356
  }
@@ -1340,15 +1404,22 @@ function semverCompare(v1, v2) {
1340
1404
  let res = 0;
1341
1405
  const parts1 = v1.split('.');
1342
1406
  const parts2 = v2.split('.');
1343
- if (parts1[0] < parts2[0]) { res = 1; }
1344
- else if (parts1[0] > parts2[0]) { res = -1; }
1345
- else if (parts1[0] === parts2[0] && parts1.length >= 2 && parts2.length >= 2) {
1346
- if (parts1[1] < parts2[1]) { res = 1; }
1347
- else if (parts1[1] > parts2[1]) { res = -1; }
1348
- else if (parts1[1] === parts2[1]) {
1407
+ if (parts1[0] < parts2[0]) {
1408
+ res = 1;
1409
+ } else if (parts1[0] > parts2[0]) {
1410
+ res = -1;
1411
+ } else if (parts1[0] === parts2[0] && parts1.length >= 2 && parts2.length >= 2) {
1412
+ if (parts1[1] < parts2[1]) {
1413
+ res = 1;
1414
+ } else if (parts1[1] > parts2[1]) {
1415
+ res = -1;
1416
+ } else if (parts1[1] === parts2[1]) {
1349
1417
  if (parts1.length >= 3 && parts2.length >= 3) {
1350
- if (parts1[2] < parts2[2]) { res = 1; }
1351
- else if (parts1[2] > parts2[2]) { res = -1; }
1418
+ if (parts1[2] < parts2[2]) {
1419
+ res = 1;
1420
+ } else if (parts1[2] > parts2[2]) {
1421
+ res = -1;
1422
+ }
1352
1423
  } else if (parts2.length >= 3) {
1353
1424
  res = 1;
1354
1425
  }
@@ -2522,10 +2593,18 @@ function getAppleModel(key) {
2522
2593
  };
2523
2594
  }
2524
2595
  const features = [];
2525
- if (list[0].size) { features.push(list[0].size); }
2526
- if (list[0].processor) { features.push(list[0].processor); }
2527
- if (list[0].year) { features.push(list[0].year); }
2528
- if (list[0].additional) { features.push(list[0].additional); }
2596
+ if (list[0].size) {
2597
+ features.push(list[0].size);
2598
+ }
2599
+ if (list[0].processor) {
2600
+ features.push(list[0].processor);
2601
+ }
2602
+ if (list[0].year) {
2603
+ features.push(list[0].year);
2604
+ }
2605
+ if (list[0].additional) {
2606
+ features.push(list[0].additional);
2607
+ }
2529
2608
  return {
2530
2609
  key: key,
2531
2610
  model: list[0].name,
@@ -2534,12 +2613,12 @@ function getAppleModel(key) {
2534
2613
  }
2535
2614
 
2536
2615
  function checkWebsite(url, timeout = 5000) {
2537
- const http = ((url.startsWith('https:') || url.indexOf(':443/') > 0 || url.indexOf(':8443/') > 0) ? require('https') : require('http'));
2616
+ const http = url.startsWith('https:') || url.indexOf(':443/') > 0 || url.indexOf(':8443/') > 0 ? require('https') : require('http');
2538
2617
  const t = Date.now();
2539
2618
  return new Promise((resolve) => {
2540
2619
  const request = http
2541
2620
  .get(url, function (res) {
2542
- res.on('data', () => { });
2621
+ res.on('data', () => {});
2543
2622
  res.on('end', () => {
2544
2623
  resolve({
2545
2624
  url,
@@ -2549,7 +2628,7 @@ function checkWebsite(url, timeout = 5000) {
2549
2628
  });
2550
2629
  });
2551
2630
  })
2552
- .on("error", function (e) {
2631
+ .on('error', function (e) {
2553
2632
  resolve({
2554
2633
  url,
2555
2634
  statusCode: 404,
@@ -2567,12 +2646,12 @@ function checkWebsite(url, timeout = 5000) {
2567
2646
  });
2568
2647
  });
2569
2648
  });
2570
- };
2649
+ }
2571
2650
 
2572
2651
  function cleanString(str) {
2573
2652
  return str.replace(/To Be Filled By O.E.M./g, '');
2574
2653
  }
2575
- function noop() { }
2654
+ function noop() {}
2576
2655
 
2577
2656
  exports.toInt = toInt;
2578
2657
  exports.splitByNumber = splitByNumber;