From b4bdc820d7426f68793befb9082d077bac384a55 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sun, 13 May 2018 19:12:21 +0200 Subject: [PATCH] bugfix system() and flags() Raspberry Pi --- CHANGELOG.md | 1 + README.md | 2 +- lib/cpu.js | 30 +++++++++++++++--------------- lib/system.js | 7 +++++-- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a04d6d..badd7d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -100,6 +100,7 @@ Other changes | Version | Date | Comment | | -------------- | -------------- | -------- | +| 3.41.2 | 2018-05-13 | bugfix `system()` and `flags()` Raspberry Pi | | 3.41.1 | 2018-05-11 | updated docs | | 3.41.0 | 2018-05-11 | `system()` Raspberry Pi bugfix and extended detection, added partial `SunOS` support | | 3.40.1 | 2018-05-10 | bugfix `system().sku` (windows) | diff --git a/README.md b/README.md index 43d24a2..18d71d8 100644 --- a/README.md +++ b/README.md @@ -226,7 +226,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] ( | | release | X | X | X | X | X | | | | codename | | | X | | | | | | kernel | X | X | X | X | X | kernel release - same as os.release() | -| | arch | X | X | X | X | | X | same as os.arch() | +| | arch | X | X | X | X | X | same as os.arch() | | | hostname | X | X | X | X | X | same as os.hostname() | | | logofile | X | X | X | X | X | e.g. 'apple', 'debian', 'fedora', ... | | si.versions(cb) | {...} | X | X | X | X | X | version information (kernel, ssl, node, ...) | diff --git a/lib/cpu.js b/lib/cpu.js index 6529ec7..ef4a32b 100644 --- a/lib/cpu.js +++ b/lib/cpu.js @@ -613,8 +613,19 @@ function cpuFlags(callback) { } }); } - if (callback) { callback(result); } - resolve(result); + if (!result) { + exec('cat /proc/cpuinfo', function (error, stdout) { + if (!error) { + let lines = stdout.toString().split('\n'); + result = util.getValue(lines, 'features', ':', true).toLowerCase(); + } + if (callback) { callback(result); } + resolve(result); + }); + } else { + if (callback) { callback(result); } + resolve(result); + } }); } if (_freebsd || _openbsd) { @@ -631,19 +642,8 @@ function cpuFlags(callback) { }); } result = flags.join(' ').trim(); - if (!result) { - exec('cat /proc/cpuinfo', function (error, stdout) { - if (!error) { - let lines = stdout.toString().split('\n'); - result = util.getValue(lines, 'features', ':', true).toLowerCase(); - } - if (callback) { callback(result); } - resolve(result); - }); - } else { - if (callback) { callback(result); } - resolve(result); - } + if (callback) { callback(result); } + resolve(result); }); } if (_darwin) { diff --git a/lib/system.js b/lib/system.js index 1dbb24f..eda9542 100644 --- a/lib/system.js +++ b/lib/system.js @@ -63,8 +63,8 @@ function system(callback) { if (fs.existsSync('/.dockerenv') || fs.existsSync('/.dockerinit')) { result.model = 'Docker Container'; } - if (result.manufacturer === '' && result.model === 'Computer' && result.version === '-') { // still default values - exec('dmesg | grep -i virtual | grep -iE "vmware|qemu|kvm|xen"', function (error, stdout) { + if (result.manufacturer === '' && result.model === 'Computer' && result.version === '') { // still default values + exec('dmesg | grep -i virtual | grep -iE "vmware|qemu|kvm|xen"', function (error, stdout) { // detect virtual machines if (!error) { let lines = stdout.toString().split('\n'); @@ -162,6 +162,9 @@ function system(callback) { resolve(result); } }); + } else { + if (callback) { callback(result); } + resolve(result); } }); }