homebridge-lib 5.3.1 → 5.3.2-0

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/SystemInfo.js +18 -21
  2. package/package.json +1 -1
package/lib/SystemInfo.js CHANGED
@@ -293,29 +293,26 @@ class SystemInfo extends events.EventEmitter {
293
293
  }
294
294
  }
295
295
  }
296
- text = await this.exec(
297
- 'plutil', '-convert', 'json', '-o', '-',
298
- process.env.HOME + '/Library/Preferences/com.apple.SystemProfiler.plist'
299
- )
300
- const s = JSON.parse(text)['CPU Names']
301
- if (s != null) {
302
- // This is empty on my MacBook Pro (14-inch, 2021).
303
- for (const key of Object.keys(s)) {
304
- if (key.startsWith(id.slice(-4))) {
305
- prettyName = s[key]
296
+ try {
297
+ if (process.arch === 'x64') { // Intel
298
+ text = await this.exec(
299
+ 'plutil', '-p',
300
+ process.env.HOME + '/Library/Preferences/com.apple.SystemProfiler.plist'
301
+ )
302
+ const regexp = RegExp('"' + id.slice(-4) + '.*" => "(.*)"')
303
+ const a = regexp.exec(text)
304
+ if (a[1] != null) {
305
+ prettyName = a[1]
306
+ }
307
+ } else { // Apple silicon
308
+ text = await this.execShell('ioreg -l | grep product-description')
309
+ const a = /"product-description" = <"([^"]*)">/.exec(text)
310
+ if (a != null) {
311
+ prettyName = a[1]
306
312
  }
307
313
  }
308
- } else {
309
- // text = await this.exec(
310
- // 'ioreg', '-c', 'IOPlatformDevice', '-d', '4', '-n', 'product'
311
- // )
312
- text = await this.execShell('ioreg -l | grep product-description')
313
- // This is empty on my Intel Macs - I think the key is registered for
314
- // running iPad apps on Apple chips.
315
- const a = /"product-description" = <"([^"]*)">/.exec(text)
316
- if (a != null) {
317
- prettyName = a[1]
318
- }
314
+ } catch (error) {
315
+ this.emit('error', error)
319
316
  }
320
317
  return {
321
318
  id: id,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Library for homebridge plugins",
4
4
  "author": "Erik Baauw",
5
5
  "license": "Apache-2.0",
6
- "version": "5.3.1",
6
+ "version": "5.3.2-0",
7
7
  "keywords": [
8
8
  "homekit",
9
9
  "homebridge"