From 9d887338e8625b76de44699a1ab1e1b90191fa22 Mon Sep 17 00:00:00 2001 From: Kiran Niranjan Date: Mon, 8 Jul 2019 12:51:29 +0530 Subject: [PATCH] ELECTRON-1358 - Move setting shell path to main.ts to prevent multiple instance issue (#704) --- src/app/init.ts | 28 +--------------------------- src/app/main.ts | 26 ++++++++++++++++++++++++++ src/app/spell-check-handler.ts | 1 - 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/app/init.ts b/src/app/init.ts index a1b64ac6..1645ae1e 100644 --- a/src/app/init.ts +++ b/src/app/init.ts @@ -1,8 +1,7 @@ import { app } from 'electron'; import * as path from 'path'; -import * as shellPath from 'shell-path'; -import { isDevEnv, isMac } from '../common/env'; +import { isDevEnv } from '../common/env'; import { logger } from '../common/logger'; import { getCommandLineArgs } from '../common/utils'; import { appStats } from './stats'; @@ -28,30 +27,5 @@ logger.info(`init: Fetch user data path`, app.getPath('userData')); // Log app statistics appStats.logStats(); -// Setting the env path child_process issue https://github.com/electron/electron/issues/7688 -(async () => { - try { - const paths = await shellPath(); - if (paths) { - return process.env.PATH = paths; - } - if (isMac) { - process.env.PATH = [ - './node_modules/.bin', - '/usr/local/bin', - process.env.PATH, - ].join(':'); - } - } catch (e) { - if (isMac) { - process.env.PATH = [ - './node_modules/.bin', - '/usr/local/bin', - process.env.PATH, - ].join(':'); - } - } -})(); - // tslint:disable-next-line require('./main'); diff --git a/src/app/main.ts b/src/app/main.ts index e3f5d4f7..b71da4e3 100644 --- a/src/app/main.ts +++ b/src/app/main.ts @@ -1,4 +1,5 @@ import { app } from 'electron'; +import * as shellPath from 'shell-path'; import { buildNumber, clientVersion, version } from '../../package.json'; import { isDevEnv, isMac } from '../common/env'; @@ -19,6 +20,31 @@ logger.info(`App started with the args ${JSON.stringify(process.argv)}`); const allowMultiInstance: string | boolean = getCommandLineArgs(process.argv, '--multiInstance', true) || isDevEnv; let isAppAlreadyOpen: boolean = false; +// Setting the env path child_process issue https://github.com/electron/electron/issues/7688 +(async () => { + try { + const paths = await shellPath(); + if (paths) { + return process.env.PATH = paths; + } + if (isMac) { + process.env.PATH = [ + './node_modules/.bin', + '/usr/local/bin', + process.env.PATH, + ].join(':'); + } + } catch (e) { + if (isMac) { + process.env.PATH = [ + './node_modules/.bin', + '/usr/local/bin', + process.env.PATH, + ].join(':'); + } + } +})(); + handlePerformanceSettings(); setChromeFlags(); diff --git a/src/app/spell-check-handler.ts b/src/app/spell-check-handler.ts index 468457cd..1dda83dc 100644 --- a/src/app/spell-check-handler.ts +++ b/src/app/spell-check-handler.ts @@ -54,7 +54,6 @@ export class SpellChecker { webContents.on('context-menu', contextMenuListener); webContents.once('destroyed', () => { - logger.info(`spell-check-handler: web contents destroyed, removing context menu listener!`); webContents.removeListener('context-menu', contextMenuListener); }); }