From 018d5f26aa482594d7a9a956e27a514304714a7b Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sat, 26 Feb 2022 07:30:41 +0100 Subject: [PATCH] fixed parsing issues (windows) --- CHANGELOG.md | 1 + docs/history.html | 5 +++++ docs/index.html | 6 +++--- lib/filesystem.js | 30 ++++++++++++++++++------------ lib/network.js | 4 ++-- lib/users.js | 8 ++++---- 6 files changed, 33 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c5b2cb..a474e29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,6 +80,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 5.11.5 | 2022-02-26 | fixed parsing issues (windows) | | 5.11.4 | 2022-02-20 | `powerShell` execution policy fix (windows) | | 5.11.3 | 2022-02-14 | updated docs | | 5.11.2 | 2022-02-05 | `powerShell` speed improvements (windows) | diff --git a/docs/history.html b/docs/history.html index 2f1d2c7..5308e49 100644 --- a/docs/history.html +++ b/docs/history.html @@ -57,6 +57,11 @@ + + 5.11.5 + 2022-02-26 + fixed parsing issues (windows) + 5.11.4 2022-02-20 diff --git a/docs/index.html b/docs/index.html index 3dd2104..a06fc8f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -170,7 +170,7 @@
systeminformation
 
-
New Version: 5.11.4
+
New Version: 5.11.5
@@ -206,7 +206,7 @@
-
15,194
+
15,199
Lines of code
@@ -214,7 +214,7 @@
Downloads last month
-
517
+
523
Dependents
diff --git a/lib/filesystem.js b/lib/filesystem.js index 9cc5809..50d9b05 100644 --- a/lib/filesystem.js +++ b/lib/filesystem.js @@ -1239,20 +1239,26 @@ function diskLayout(callback) { // S.M.A.R.T data.results.shift(); data.results.shift(); - data.results.forEach((smartStr) => { - const smartData = JSON.parse(smartStr); - if (smartData.serial_number) { - const serialNum = smartData.serial_number; - let i = util.findObjectByKey(result, 'serialNum', serialNum); - if (i != -1) { - result[i].smartStatus = (smartData.smart_status.passed ? 'Ok' : (smartData.smart_status.passed === false ? 'Predicted Failure' : 'unknown')); - if (smartData.temperature && smartData.temperature.current) { - result[i].temperature = smartData.temperature.current; + if (data.results.length) { + data.results.forEach((smartStr) => { + try { + const smartData = JSON.parse(smartStr); + if (smartData.serial_number) { + const serialNum = smartData.serial_number; + let i = util.findObjectByKey(result, 'serialNum', serialNum); + if (i != -1) { + result[i].smartStatus = (smartData.smart_status.passed ? 'Ok' : (smartData.smart_status.passed === false ? 'Predicted Failure' : 'unknown')); + if (smartData.temperature && smartData.temperature.current) { + result[i].temperature = smartData.temperature.current; + } + result[i].smartData = smartData; + } } - result[i].smartData = smartData; + } catch (e) { + util.noop(); } - } - }); + }); + } if (callback) { callback(result); } diff --git a/lib/network.js b/lib/network.js index 4756691..6cac748 100644 --- a/lib/network.js +++ b/lib/network.js @@ -254,8 +254,8 @@ function getWindowsNics() { try { util.powerShell(cmd).then(data => { data = data.split('#-#-#-#'); - const nsections = data[0].split(/\n\s*\n/); - const nconfigsections = data[1].split(/\n\s*\n/); + const nsections = (data[0] || '').split(/\n\s*\n/); + const nconfigsections = (data[1] || '').split(/\n\s*\n/); resolve(parseLinesWindowsNics(nsections, nconfigsections)); }); } catch (e) { diff --git a/lib/users.js b/lib/users.js index 0ea040a..dee4c57 100644 --- a/lib/users.js +++ b/lib/users.js @@ -262,10 +262,10 @@ function users(callback) { // let accounts = parseWinAccounts(data[0].split(/\n\s*\n/)); if (data) { data = data.split('#-#-#-#'); - let sessions = parseWinSessions(data[0].split(/\n\s*\n/)); - let loggedons = parseWinLoggedOn(data[1].split(/\n\s*\n/)); - let queryUser = parseWinUsersQuery(data[3].split('\r\n')); - let users = parseWinUsers(data[2].split(/\n\s*\n/), queryUser); + let sessions = parseWinSessions((data[0] || '').split(/\n\s*\n/)); + let loggedons = parseWinLoggedOn((data[1] || '').split(/\n\s*\n/)); + let queryUser = parseWinUsersQuery((data[3] || '').split('\r\n')); + let users = parseWinUsers((data[2] || '').split(/\n\s*\n/), queryUser); for (let id in loggedons) { if ({}.hasOwnProperty.call(loggedons, id)) { loggedons[id].dateTime = {}.hasOwnProperty.call(sessions, id) ? sessions[id] : '';