diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2022-10-06 15:10:26 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-10-06 15:10:26 +0200 |
| commit | da20724b9f69caa2132d7d0fa93c7d64ecfe1d65 (patch) | |
| tree | e615de7c9b747e46748873aa5cd244a5359cd12a /gui/src/main | |
| parent | 19e36fb3168ed41c5f52806a55ff0e13cc223cbe (diff) | |
| download | mullvadvpn-da20724b9f69caa2132d7d0fa93c7d64ecfe1d65.tar.xz mullvadvpn-da20724b9f69caa2132d7d0fa93c7d64ecfe1d65.zip | |
Simplify command line argument checking
Diffstat (limited to 'gui/src/main')
| -rw-r--r-- | gui/src/main/command-line-options.ts | 13 | ||||
| -rw-r--r-- | gui/src/main/index.ts | 12 | ||||
| -rw-r--r-- | gui/src/main/user-interface.ts | 4 |
3 files changed, 22 insertions, 7 deletions
diff --git a/gui/src/main/command-line-options.ts b/gui/src/main/command-line-options.ts index 26cb89887a..543a384029 100644 --- a/gui/src/main/command-line-options.ts +++ b/gui/src/main/command-line-options.ts @@ -1,6 +1,17 @@ -export enum CommandLineOptions { +enum CommandLineOptions { showChanges = '--show-changes', disableResetNavigation = '--disable-reset-navigation', // development only disableDevtoolsOpen = '--disable-devtools-open', // development only forwardRendererLog = '--forward-renderer-log', // development only } + +export const SHOULD_SHOW_CHANGES = process.argv.includes(CommandLineOptions.showChanges); +export const SHOULD_DISABLE_RESET_NAVIGATION = process.argv.includes( + CommandLineOptions.disableResetNavigation, +); +export const SHOULD_DISABLE_DEVTOOLS_OPEN = process.argv.includes( + CommandLineOptions.disableDevtoolsOpen, +); +export const SHOULD_FORWARD_RENDERER_LOG = process.argv.includes( + CommandLineOptions.forwardRendererLog, +); diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index e99dcd8e67..e6336b1d18 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -18,7 +18,11 @@ import { SystemNotification } from '../shared/notifications/notification'; import Account, { AccountDelegate, LocaleProvider } from './account'; import { getOpenAtLogin } from './autostart'; import { readChangelog } from './changelog'; -import { CommandLineOptions } from './command-line-options'; +import { + SHOULD_DISABLE_RESET_NAVIGATION, + SHOULD_FORWARD_RENDERER_LOG, + SHOULD_SHOW_CHANGES, +} from './command-line-options'; import { ConnectionObserver, DaemonRpc, SubscriptionListener } from './daemon-rpc'; import Expectation from './expectation'; import { IpcMainEventChannel } from './ipc-event-channel'; @@ -248,7 +252,7 @@ class ApplicationMain const rendererLogPath = getRendererLogPath(); if (process.env.NODE_ENV === 'development') { - if (process.argv.includes(CommandLineOptions.forwardRendererLog)) { + if (SHOULD_FORWARD_RENDERER_LOG) { log.addInput(new IpcInput()); } } else { @@ -389,7 +393,7 @@ class ApplicationMain this, this.daemonRpc, SANDBOX_DISABLED, - process.argv.includes(CommandLineOptions.disableResetNavigation), + SHOULD_DISABLE_RESET_NAVIGATION, ); this.tunnelStateExpectation = new Expectation(async () => { @@ -693,7 +697,7 @@ class ApplicationMain windowsSplitTunnelingApplications: this.windowsSplitTunnelingApplications, macOsScrollbarVisibility: this.macOsScrollbarVisibility, changelog: this.changelog ?? [], - forceShowChanges: process.argv.includes(CommandLineOptions.showChanges), + forceShowChanges: SHOULD_SHOW_CHANGES, navigationHistory: this.navigationHistory, scrollPositions: this.scrollPositions, })); diff --git a/gui/src/main/user-interface.ts b/gui/src/main/user-interface.ts index 70a86284bb..4d56d95eac 100644 --- a/gui/src/main/user-interface.ts +++ b/gui/src/main/user-interface.ts @@ -8,7 +8,7 @@ import { IAccountData, ILocation, TunnelState } from '../shared/daemon-rpc-types import { messages, relayLocations } from '../shared/gettext'; import log from '../shared/logging'; import { Scheduler } from '../shared/scheduler'; -import { CommandLineOptions } from './command-line-options'; +import { SHOULD_DISABLE_DEVTOOLS_OPEN } from './command-line-options'; import { DaemonRpc } from './daemon-rpc'; import { changeIpcWebContents, IpcMainEventChannel } from './ipc-event-channel'; import { isMacOs11OrNewer } from './platform-version'; @@ -88,7 +88,7 @@ export default class UserInterface implements WindowControllerDelegate { if (process.env.NODE_ENV === 'development') { await this.installDevTools(); - if (!process.argv.includes(CommandLineOptions.disableDevtoolsOpen)) { + if (!SHOULD_DISABLE_DEVTOOLS_OPEN) { // The devtools doesn't open on Windows if openDevTools is called without a delay here. window.once('ready-to-show', () => window.webContents.openDevTools({ mode: 'detach' })); } |
