From 520f05d7dba8d253542be903802755242e557249 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Wed, 31 Dec 2025 07:12:28 +0100 Subject: [PATCH] npx systeminformation improved output --- CHANGELOG.md | 1 + docs/history.html | 5 +++++ docs/index.html | 2 +- lib/cli.js | 35 ++++++++++++++++++++++------------- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27ecbf8..d2612da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -90,6 +90,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page. | Version | Date | Comment | | ------- | ---------- | --------------------------------------------------------------------------------------------------- | +| 5.28.6 | 2025-12-31 | `npx systeminformation` improved output | | 5.28.5 | 2025-12-30 | `cpuCurrentSpeed()` fix cpu loop issue | | 5.28.4 | 2025-12-29 | `powerShell()` Windows 7 fix compatibility issues (windows) | | 5.28.3 | 2025-12-28 | `processes()`, `processLoad()` fix command line parsing (windows) | diff --git a/docs/history.html b/docs/history.html index a4422e6..9b229da 100644 --- a/docs/history.html +++ b/docs/history.html @@ -57,6 +57,11 @@ + + 5.28.6 + 2025-12-31 + npx systeminformation improved output + 5.28.5 2025-12-30 diff --git a/docs/index.html b/docs/index.html index 43d039a..ea457ed 100644 --- a/docs/index.html +++ b/docs/index.html @@ -170,7 +170,7 @@
systeminformation
 
-
New Version: 5.28.5
+
New Version: 5.28.6
diff --git a/lib/cli.js b/lib/cli.js index cfccb95..f5d0e8d 100755 --- a/lib/cli.js +++ b/lib/cli.js @@ -23,19 +23,31 @@ function capFirst(string) { return string[0].toUpperCase() + string.slice(1); } +function getValue(value) { + if (value === null || value === undefined) { + return ''; + } + if (typeof value === 'object') { + return JSON.stringify(value); + } + return value.toString(); +} + function printLines(obj) { for (const property in obj) { - console.log(capFirst(property) + ' '.substring(0, 17 - property.length) + ': ' + (obj[property] || '')); + console.log(`${capFirst(property) + ' '.substring(0, 17 - property.length)}: ${getValue(obj[property])}`); } console.log(); } function info() { console.log('┌─────────────────────────────────────────────────────────────────────────────────────────┐'); - console.log('│ SYSTEMINFORMATION '.substring(0, 80 - lib_version.length) + 'Version: ' + lib_version + ' │'); + console.log( + `${'│ SYSTEMINFORMATION '.substring(0, 80 - lib_version.length)}Version: ${lib_version} │` + ); console.log('└─────────────────────────────────────────────────────────────────────────────────────────┘'); - si.osInfo().then(res => { + si.osInfo().then((res) => { console.log(); console.log('Operating System:'); console.log('──────────────────────────────────────────────────────────────────────────────────────────'); @@ -45,7 +57,7 @@ function info() { delete res.fqdn; delete res.uefi; printLines(res); - si.system().then(res => { + si.system().then((res) => { console.log('System:'); console.log('──────────────────────────────────────────────────────────────────────────────────────────'); delete res.serial; @@ -53,7 +65,7 @@ function info() { delete res.sku; delete res.uuid; printLines(res); - si.cpu().then(res => { + si.cpu().then((res) => { console.log('CPU:'); console.log('──────────────────────────────────────────────────────────────────────────────────────────'); delete res.cache; @@ -74,18 +86,15 @@ function info() { // ---------------------------------------------------------------------------------- // Main // ---------------------------------------------------------------------------------- -(function () { +(() => { const args = process.argv.slice(2); if (args[0] === 'info') { info(); } else { - si.getStaticData().then( - ((data) => { - data.time = si.time(); - console.log(JSON.stringify(data, null, 2)); - } - )); + si.getStaticData().then((data) => { + data.time = si.time(); + console.log(JSON.stringify(data, null, 2)); + }); } - })();