From 6c222d4dcc254ac62cdef8f1140be1ab840b1e09 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Thu, 17 Dec 2020 23:01:26 +0100 Subject: [PATCH] cpu() Apple Silicon M1 mem --- lib/cpu.js | 8 ++++---- lib/memory.js | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/lib/cpu.js b/lib/cpu.js index bf296d3..2e23e35 100644 --- a/lib/cpu.js +++ b/lib/cpu.js @@ -410,7 +410,7 @@ function getCpu() { cache: {} }; if (_darwin) { - exec('sysctl machdep.cpu hw.cpufrequency_max hw.cpufrequency_min hw.packages hw.physicalcpu_max hw.ncpu hw.tbfrequency', function (error, stdout) { + exec('sysctl machdep.cpu hw.cpufrequency_max hw.cpufrequency_min hw.packages hw.physicalcpu_max hw.ncpu hw.tbfrequency hw.cpufamily hw.cpusubfamily', function (error, stdout) { let lines = stdout.toString().split('\n'); const modelline = util.getValue(lines, 'machdep.cpu.brand_string'); const modellineParts = modelline.split('@'); @@ -425,10 +425,10 @@ function getCpu() { result = cpuBrandManufacturer(result); result.speedmin = util.getValue(lines, 'hw.cpufrequency_min') ? (util.getValue(lines, 'hw.cpufrequency_min') / 1000000000.0).toFixed(2) : result.speed; result.speedmax = util.getValue(lines, 'hw.cpufrequency_max') ? (util.getValue(lines, 'hw.cpufrequency_max') / 1000000000.0).toFixed(2) : result.speed; - result.vendor = util.getValue(lines, 'machdep.cpu.vendor'); - result.family = util.getValue(lines, 'machdep.cpu.family'); + result.vendor = util.getValue(lines, 'machdep.cpu.vendor') || 'Apple'; + result.family = util.getValue(lines, 'machdep.cpu.family') || util.getValue(lines, 'hw.cpufamily'); result.model = util.getValue(lines, 'machdep.cpu.model'); - result.stepping = util.getValue(lines, 'machdep.cpu.stepping'); + result.stepping = util.getValue(lines, 'machdep.cpu.stepping') || util.getValue(lines, 'hw.cpusubfamily'); const countProcessors = util.getValue(lines, 'hw.packages'); const countCores = util.getValue(lines, 'hw.physicalcpu_max'); const countThreads = util.getValue(lines, 'hw.ncpu'); diff --git a/lib/memory.js b/lib/memory.js index e6b23c6..b035fd9 100644 --- a/lib/memory.js +++ b/lib/memory.js @@ -422,6 +422,27 @@ function memLayout(callback) { } }); } + if (!result.length) { + const lines = stdout.toString().split('\n'); + const size = parseInt(util.getValue(lines, ' Memory:')); + const type = parseInt(util.getValue(lines, ' Type:'),); + if (size && type) { + result.push({ + size, + bank: 0, + type, + clockSpeed: 0, + formFactor: '', + manufacturer: '', + partNum: '', + serialNum: '', + voltageConfigured: -1, + voltageMin: -1, + voltageMax: -1, + }); + + } + } if (callback) { callback(result); } resolve(result); });