summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2022-10-06 16:23:00 +0200
committerOskar Nyberg <oskar@mullvad.net>2022-10-06 16:23:00 +0200
commit87ebe7bc4cfe70021afd5fb528e9e9b734c5ec88 (patch)
treee615de7c9b747e46748873aa5cd244a5359cd12a
parent41ae2978f2b4ffba4f968bc04c4818bb1914d138 (diff)
parentda20724b9f69caa2132d7d0fa93c7d64ecfe1d65 (diff)
downloadmullvadvpn-87ebe7bc4cfe70021afd5fb528e9e9b734c5ec88.tar.xz
mullvadvpn-87ebe7bc4cfe70021afd5fb528e9e9b734c5ec88.zip
Merge branch 'add-option-to-run-without-opening-devtools'
-rw-r--r--gui/src/main/command-line-options.ts17
-rw-r--r--gui/src/main/index.ts20
-rw-r--r--gui/src/main/user-interface.ts7
-rw-r--r--gui/tasks/electron.js8
4 files changed, 35 insertions, 17 deletions
diff --git a/gui/src/main/command-line-options.ts b/gui/src/main/command-line-options.ts
new file mode 100644
index 0000000000..543a384029
--- /dev/null
+++ b/gui/src/main/command-line-options.ts
@@ -0,0 +1,17 @@
+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 9a396d4307..e6336b1d18 100644
--- a/gui/src/main/index.ts
+++ b/gui/src/main/index.ts
@@ -18,6 +18,11 @@ import { SystemNotification } from '../shared/notifications/notification';
import Account, { AccountDelegate, LocaleProvider } from './account';
import { getOpenAtLogin } from './autostart';
import { readChangelog } from './changelog';
+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';
@@ -54,11 +59,6 @@ const execAsync = util.promisify(exec);
const linuxSplitTunneling = process.platform === 'linux' && require('./linux-split-tunneling');
const windowsSplitTunneling = process.platform === 'win32' && require('./windows-split-tunneling');
-enum CommandLineOptions {
- showChanges = '--show-changes',
- disableResetNavigation = '--disable-reset-navigation', // development only
-}
-
const ALLOWED_PERMISSIONS = ['clipboard-sanitized-write'];
const SANDBOX_DISABLED = app.commandLine.hasSwitch('no-sandbox');
@@ -251,7 +251,11 @@ class ApplicationMain
const mainLogPath = getMainLogPath();
const rendererLogPath = getRendererLogPath();
- if (process.env.NODE_ENV !== 'development') {
+ if (process.env.NODE_ENV === 'development') {
+ if (SHOULD_FORWARD_RENDERER_LOG) {
+ log.addInput(new IpcInput());
+ }
+ } else {
this.rendererLog = new Logger();
this.rendererLog.addInput(new IpcInput());
@@ -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 712d7e42b8..4d56d95eac 100644
--- a/gui/src/main/user-interface.ts
+++ b/gui/src/main/user-interface.ts
@@ -8,6 +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 { 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';
@@ -87,8 +88,10 @@ export default class UserInterface implements WindowControllerDelegate {
if (process.env.NODE_ENV === 'development') {
await this.installDevTools();
- // 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' }));
+ 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' }));
+ }
}
switch (process.platform) {
diff --git a/gui/tasks/electron.js b/gui/tasks/electron.js
index 3469756397..e3360f36fb 100644
--- a/gui/tasks/electron.js
+++ b/gui/tasks/electron.js
@@ -1,16 +1,10 @@
const { spawn } = require('child_process');
const electron = require('electron');
-const DISABLE_RESET_NAVIGATION = '--disable-reset-navigation';
-
let subprocess;
function startElectron(done) {
- const args = [];
- if (process.argv.includes(DISABLE_RESET_NAVIGATION)) {
- args.push(DISABLE_RESET_NAVIGATION);
- }
-
+ const args = process.argv.slice(3);
subprocess = spawn(electron, ['.', ...args], {
env: { ...process.env, NODE_ENV: 'development' },
stdio: 'inherit',