ELECTRON-1358 - Move setting shell path to main.ts to prevent multiple instance issue (#704)

This commit is contained in:
Kiran Niranjan 2019-07-08 12:51:29 +05:30 committed by Vishwas Shashidhar
parent 494b886045
commit 9d887338e8
3 changed files with 27 additions and 28 deletions

View File

@ -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');

View File

@ -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();

View File

@ -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);
});
}