From 4bfd0c3ea50ea16ee59c64c8f116c04d932df44d Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sun, 5 Jan 2025 07:43:53 +0100 Subject: [PATCH] currentSpeed() added try catch --- lib/cpu.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/cpu.js b/lib/cpu.js index 118caf7..a7942d8 100644 --- a/lib/cpu.js +++ b/lib/cpu.js @@ -1001,10 +1001,14 @@ function getCpuCurrentSpeedSync() { for (let i in cpus) { speeds.push(cpus[i].speed > 100 ? (cpus[i].speed + 1) / 1000 : cpus[i].speed / 10); } - } else { - speedStrings = execSync('cat /proc/cpuinfo | grep "cpu MHz" | cut -d " " -f 3', util.execOptsLinux).toString().split('\n'); - for (let i in speedStrings) { - speeds.push(parseInt(speedStrings, 10)); + } else if (_linux) { + try { + speedStrings = execSync('cat /proc/cpuinfo | grep "cpu MHz" | cut -d " " -f 3', util.execOptsLinux).toString().split('\n'); + for (let i in speedStrings) { + speeds.push(parseInt(speedStrings, 10)); + } + } catch { + util.noop(); } }