From ab5e4e998c7a816909226238ff5121a3a3f0c75f Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Thu, 21 Nov 2019 13:48:17 -0800 Subject: [PATCH] Fix reduce usage --- CHANGES | 3 +++ src/system.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 5e6f052e3..d6d24604d 100644 --- a/CHANGES +++ b/CHANGES @@ -1735,3 +1735,6 @@ * Add 'New Apps' section to Appstore view * Fix issue where graphs of some apps were not appearing +[4.3.5] +* Show swap in graphs + diff --git a/src/system.js b/src/system.js index 5eb37c68b..18b6782af 100644 --- a/src/system.js +++ b/src/system.js @@ -102,7 +102,7 @@ function getMemory(callback) { assert.strictEqual(typeof callback, 'function'); const stdout = safe.child_process.execSync('swapon --noheadings --raw --bytes --show=SIZE', { encoding: 'utf8' }); - const swap = !stdout ? 0 : stdout.split('\n').reduce((acc, cur) => acc + (parseInt(cur, 0) || 0)); + const swap = !stdout ? 0 : stdout.trim().split('\n').map(x => parseInt(x, 10) || 0).reduce((acc, cur) => acc + cur); callback(null, { memory: os.totalmem(),