From 12455253ddb530577c3b111e08c34f4cb2990782 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Tue, 13 Jan 2026 21:14:33 +0100 Subject: [PATCH] code cleanup --- lib/users.js | 2 +- lib/virtualbox.js | 8 ++++---- lib/wifi.js | 18 +++++++++--------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/users.js b/lib/users.js index d277765..dd50772 100644 --- a/lib/users.js +++ b/lib/users.js @@ -290,7 +290,7 @@ function users(callback) { } resolve(result); }); - } catch (e) { + } catch { if (callback) { callback(result); } diff --git a/lib/virtualbox.js b/lib/virtualbox.js index 0f5a787..ae2daeb 100644 --- a/lib/virtualbox.js +++ b/lib/virtualbox.js @@ -23,7 +23,7 @@ function vboxInfo(callback) { return new Promise((resolve) => { process.nextTick(() => { try { - exec(util.getVboxmanage() + ' list vms --long', function (error, stdout) { + exec(util.getVboxmanage() + ' list vms --long', (error, stdout) => { let parts = (os.EOL + stdout.toString()).split(os.EOL + 'Name:'); parts.shift(); parts.forEach((part) => { @@ -38,7 +38,7 @@ function vboxInfo(callback) { const offset = sinceDateObj.getTimezoneOffset(); runningSince = Math.round((Date.now() - Date.parse(sinceDateObj)) / 1000) + offset * 60; } - } catch (e) { + } catch { util.noop(); } const stoppedSinceString = !running ? state.replace('powered off (since', '').replace(')', '').trim() : ''; @@ -49,7 +49,7 @@ function vboxInfo(callback) { const offset = sinceDateObj.getTimezoneOffset(); stoppedSince = Math.round((Date.now() - Date.parse(sinceDateObj)) / 1000) + offset * 60; } - } catch (e) { + } catch { util.noop(); } result.push({ @@ -97,7 +97,7 @@ function vboxInfo(callback) { } resolve(result); }); - } catch (e) { + } catch { if (callback) { callback(result); } diff --git a/lib/wifi.js b/lib/wifi.js index 88bafb6..0fd3a60 100644 --- a/lib/wifi.js +++ b/lib/wifi.js @@ -157,7 +157,7 @@ function ifaceListLinux() { }); }); return result; - } catch (e) { + } catch { try { const all = execSync('nmcli -t -f general,wifi-properties,wired-properties,interface-flags,capabilities,nsp device show 2>/dev/null', util.execOptsLinux).toString(); const parts = all.split('\n\n'); @@ -179,7 +179,7 @@ function ifaceListLinux() { } }); return result; - } catch (e) { + } catch { return []; } } @@ -198,7 +198,7 @@ function nmiDeviceLinux(iface) { mac: util.getValue(lines, 'GENERAL.HWADDR').toLowerCase(), ssid: ssid !== '--' ? ssid : null }; - } catch (e) { + } catch { return {}; } } @@ -216,7 +216,7 @@ function nmiConnectionLinux(ssid) { security: util.getValue(lines, '802-11-wireless-security.key-mgmt'), bssid: bssid !== '--' ? bssid : null }; - } catch (e) { + } catch { return {}; } } @@ -237,7 +237,7 @@ function wpaConnectionLinux(iface) { channel: wifiChannelFromFrequencs(freq), bssid: util.getValue(lines, 'bssid', '=').toLowerCase() }; - } catch (e) { + } catch { return {}; } } @@ -272,7 +272,7 @@ function getWifiNetworkListNmi() { }); }); return result; - } catch (e) { + } catch { return []; } } @@ -363,7 +363,7 @@ function getWifiNetworkListIw(iface) { }); } return result; - } catch (e) { + } catch { return -1; } } @@ -404,7 +404,7 @@ function parseWifiDarwin(wifiStr) { }); }); return result; - } catch (e) { + } catch { return result; } } @@ -460,7 +460,7 @@ function wifiNetworks(callback) { } resolve(result); } - } catch (e) { + } catch { if (callback) { callback(result); }