diff --git a/js/app.js b/js/app.js index 70244f8..1d60981 100644 --- a/js/app.js +++ b/js/app.js @@ -15,7 +15,7 @@ ready(function(){ checkForAdminRights(); displayVersion(); reApplyPeriodically(require('electron-settings').get('settings.reapply_periodically')); - if (require('os').platform() === 'win32' && isDevMode()) { + if (isWindows() && isDevMode()) { recreateShortcut(); } handlePlatformSpecificDisplay(); diff --git a/js/methods.js b/js/methods.js index c686026..85cb0d9 100644 --- a/js/methods.js +++ b/js/methods.js @@ -193,7 +193,7 @@ function registerRepeaterForAllInput() { * Will display a warning if not. */ function checkForAdminRights() { - if (require('os').platform() !== 'win32') { + if (!isWindows()) { const isRoot = process.getuid && process.getuid() === 0; if (!isRoot) { notification('danger', @@ -214,6 +214,13 @@ function checkForAdminRights() { } } +/** + * Check that the app is running on Windows. + */ +function isWindows() { + return require('os').platform() === 'win32'; +} + /** * Will display a notification in ".notification-zone". * @param {string} type "primary", "warning", "danger" or "success". @@ -235,7 +242,7 @@ function notification(type, message) { function getRyzenAdjExecutablePath() { const settings = require('electron-settings'); var ryzen_adj_path = settings.get('settings.ryzen_adj_path'); - if (!ryzen_adj_path && require('os').platform() === 'win32') { + if (!ryzen_adj_path && isWindows()) { ryzen_adj_path = getCurrentWorkingDirectory() + "\\bin\\ryzenadj.exe"; } appendLog(`getRyzenAdjExecutablePath(): "${ryzen_adj_path}"`); @@ -622,7 +629,7 @@ function toggleHpet(value) { */ function handlePlatformSpecificDisplay() { var windows_only_elements = document.getElementsByClassName('windows-only'); - if (require('os').platform() !== 'win32') { + if (!isWindows()) { for (const item of windows_only_elements) { item.setAttribute('hidden', 'true'); }