[MM-19963] set working directory on start (#1105)
* [MM-19963] set current working directory for the app * prevent failing if env variables are not setup * [MM-19963] cwd if not in dev mode and only if necessary, log it if it happens * fix remove path if no cert is present * address CR suggestions
This commit is contained in:
@@ -89,7 +89,6 @@ const customLogins = {};
|
||||
*/
|
||||
async function initialize() {
|
||||
process.on('uncaughtException', criticalErrorHandler.processUncaughtExceptionHandler.bind(criticalErrorHandler));
|
||||
|
||||
global.willAppQuit = false;
|
||||
|
||||
// initialization that can run before the app is ready
|
||||
@@ -167,6 +166,13 @@ function initializeAppEventListeners() {
|
||||
function initializeBeforeAppReady() {
|
||||
certificateStore = CertificateStore.load(path.resolve(app.getPath('userData'), 'certificate.json'));
|
||||
|
||||
// prevent using a different working directory, which happens on windows running after installation.
|
||||
const expectedPath = path.dirname(process.execPath);
|
||||
if (process.cwd() !== expectedPath && !isDev) {
|
||||
console.warn(`Current working directory is ${process.cwd()}, changing into ${expectedPath}`);
|
||||
process.chdir(expectedPath);
|
||||
}
|
||||
|
||||
// can only call this before the app is ready
|
||||
if (config.enableHardwareAcceleration === false) {
|
||||
app.disableHardwareAcceleration();
|
||||
|
Reference in New Issue
Block a user