1. Set shell-path (#659)

1. Add isMac check for set path if shell path has errors.
This commit is contained in:
Keerthi Niranjan 2019-05-22 13:56:57 +05:30 committed by Vishwas Shashidhar
parent fe77bc259b
commit e094aa7fff

View File

@ -1,7 +1,8 @@
import { app } from 'electron';
import * as path from 'path';
import * as shellPath from 'shell-path';
import { isDevEnv } from '../common/env';
import { isDevEnv, isMac } from '../common/env';
import { getCommandLineArgs } from '../common/utils';
// Handle custom user data path from process.argv
@ -18,5 +19,30 @@ if (userDataPath) {
app.setPath('userData', userDataPath);
}
// 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');