diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 55829ba..e9e6c88 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - node-version: [10.x, 11.x, 12.x, 13.x, 14.x, 15.x, 16.x, 17.x, 18.x] + node-version: [10.x, 11.x, 12.x, 13.x, 14.x, 15.x, 16.x, 17.x, 18.x, 19.x] include: - os: macos-latest node-version: 14.x diff --git a/lib/memory.js b/lib/memory.js index bbf7e5c..be86156 100644 --- a/lib/memory.js +++ b/lib/memory.js @@ -245,13 +245,13 @@ function mem(callback) { if (!error) { let lines = stdout.toString().split('\n'); if (lines.length > 0) { - let line = lines[0].replace(/,/g, '.').replace(/M/g, ''); - line = line.trim().split(' '); - for (let i = 0; i < line.length; i++) { - if (line[i].toLowerCase().indexOf('total') !== -1) { result.swaptotal = parseFloat(line[i].split('=')[1].trim()) * 1024 * 1024; } - if (line[i].toLowerCase().indexOf('used') !== -1) { result.swapused = parseFloat(line[i].split('=')[1].trim()) * 1024 * 1024; } - if (line[i].toLowerCase().indexOf('free') !== -1) { result.swapfree = parseFloat(line[i].split('=')[1].trim()) * 1024 * 1024; } - } + let firstline = lines[0].replace(/,/g, '.').replace(/M/g, ''); + let lineArray = firstline.trim().split(' '); + lineArray.forEach(line => { + if (line.toLowerCase().indexOf('total') !== -1) { result.swaptotal = parseFloat(line.split('=')[1].trim()) * 1024 * 1024; } + if (line.toLowerCase().indexOf('used') !== -1) { result.swapused = parseFloat(line.split('=')[1].trim()) * 1024 * 1024; } + if (line.toLowerCase().indexOf('free') !== -1) { result.swapfree = parseFloat(line.split('=')[1].trim()) * 1024 * 1024; } + }); } } if (callback) { callback(result); } diff --git a/lib/osinfo.js b/lib/osinfo.js index e79cbcf..e784f3a 100644 --- a/lib/osinfo.js +++ b/lib/osinfo.js @@ -289,8 +289,6 @@ function osInfo(callback) { result.logofile = getLogoFile(result.distro); result.codename = 'macOS'; result.codename = (result.release.indexOf('10.4') > -1 ? 'Mac OS X Tiger' : result.codename); - result.codename = (result.release.indexOf('10.4') > -1 ? 'Mac OS X Tiger' : result.codename); - result.codename = (result.release.indexOf('10.4') > -1 ? 'Mac OS X Tiger' : result.codename); result.codename = (result.release.indexOf('10.5') > -1 ? 'Mac OS X Leopard' : result.codename); result.codename = (result.release.indexOf('10.6') > -1 ? 'Mac OS X Snow Leopard' : result.codename); result.codename = (result.release.indexOf('10.7') > -1 ? 'Mac OS X Lion' : result.codename); @@ -738,9 +736,9 @@ function versions(apps, callback) { if (_windows) { util.powerShell('Get-WmiObject Win32_Service | select caption | fl').then((stdout) => { let serviceSections = stdout.split(/\n\s*\n/); - for (let i = 0; i < serviceSections.length; i++) { - if (serviceSections[i].trim() !== '') { - let lines = serviceSections[i].trim().split('\r\n'); + serviceSections.forEach((item) => { + if (item.trim() !== '') { + let lines = item.trim().split('\r\n'); let srvCaption = util.getValue(lines, 'caption', ':', true).toLowerCase(); if (srvCaption.indexOf('postgresql') > -1) { const parts = srvCaption.split(' server '); @@ -749,7 +747,7 @@ function versions(apps, callback) { } } } - } + }); functionProcessed(); }); } else {