[MM-64867] Upgrade to Electron v37.2.2, some other package changes (#3462)
This commit is contained in:
@@ -1,13 +1,39 @@
|
||||
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
const electron = require('electron-connect').server.create({path: 'dist/'});
|
||||
const {spawn} = require('child_process');
|
||||
const path = require('path');
|
||||
|
||||
const webpack = require('webpack');
|
||||
|
||||
const mainConfig = require('../webpack.config.main.js');
|
||||
const preloadConfig = require('../webpack.config.preload.js');
|
||||
const rendererConfig = require('../webpack.config.renderer.js');
|
||||
|
||||
let electronProcess = null;
|
||||
|
||||
function startElectron() {
|
||||
if (electronProcess) {
|
||||
electronProcess.removeAllListeners();
|
||||
}
|
||||
electronProcess = spawn(
|
||||
process.platform === 'win32' ? 'electron.cmd' : 'electron',
|
||||
[path.resolve('dist/')],
|
||||
{stdio: 'inherit'},
|
||||
);
|
||||
}
|
||||
|
||||
function restartElectron() {
|
||||
if (electronProcess) {
|
||||
electronProcess.kill();
|
||||
electronProcess.on('close', () => {
|
||||
startElectron();
|
||||
});
|
||||
} else {
|
||||
startElectron();
|
||||
}
|
||||
}
|
||||
|
||||
Promise.all([mainConfig, preloadConfig, rendererConfig].map((config) => {
|
||||
return new Promise((resolve) => {
|
||||
const compiler = webpack(config);
|
||||
@@ -18,9 +44,11 @@ Promise.all([mainConfig, preloadConfig, rendererConfig].map((config) => {
|
||||
process.stdout.write(stats.toString({colors: true}));
|
||||
process.stdout.write('\n');
|
||||
if (!stats.hasErrors()) {
|
||||
electron.restart();
|
||||
restartElectron();
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
})).then(() => electron.start());
|
||||
})).then(() => {
|
||||
startElectron();
|
||||
});
|
||||
|
Reference in New Issue
Block a user