2020-06-02 10:26:47 +03:00
|
|
|
const { spawn } = require('child_process');
|
|
|
|
|
|
|
|
const electronVersion = require('./config').appMetadata.electronVersion;
|
|
|
|
|
|
|
|
if (process.env.ELECTRON_CUSTOM_VERSION !== electronVersion) {
|
2020-06-03 19:38:26 +03:00
|
|
|
const electronEnv = process.env.ELECTRON_CUSTOM_VERSION;
|
2020-06-02 10:26:47 +03:00
|
|
|
console.info(
|
|
|
|
`env var ELECTRON_CUSTOM_VERSION is not set,\n` +
|
|
|
|
`or doesn't match electronVersion in ../package.json.\n` +
|
2020-06-03 19:38:26 +03:00
|
|
|
`(is: "${electronEnv}", wanted: "${electronVersion}").\n` +
|
2020-06-02 10:26:47 +03:00
|
|
|
`Setting, and re-downloading chromedriver and mksnapshot.\n`
|
|
|
|
);
|
|
|
|
|
|
|
|
process.env.ELECTRON_CUSTOM_VERSION = electronVersion;
|
2020-06-03 19:38:26 +03:00
|
|
|
const downloadChromedriverPath = require.resolve(
|
|
|
|
'electron-chromedriver/download-chromedriver.js'
|
|
|
|
);
|
|
|
|
const downloadMksnapshotPath = require.resolve(
|
|
|
|
'electron-mksnapshot/download-mksnapshot.js'
|
|
|
|
);
|
2020-06-02 10:26:47 +03:00
|
|
|
const downloadChromedriver = spawn('node', [downloadChromedriverPath]);
|
|
|
|
const downloadMksnapshot = spawn('node', [downloadMksnapshotPath]);
|
|
|
|
var exitStatus;
|
|
|
|
|
2020-06-03 19:38:26 +03:00
|
|
|
downloadChromedriver.on('close', code => {
|
2020-06-02 10:26:47 +03:00
|
|
|
if (code === 0) {
|
2020-06-03 19:38:26 +03:00
|
|
|
exitStatus = 'success';
|
2020-06-02 10:26:47 +03:00
|
|
|
} else {
|
2020-06-03 19:38:26 +03:00
|
|
|
exitStatus = 'error';
|
2020-06-02 10:26:47 +03:00
|
|
|
}
|
|
|
|
|
2020-06-03 19:38:26 +03:00
|
|
|
console.info(
|
|
|
|
`info: Done re-downloading chromedriver. Status: ${exitStatus}`
|
|
|
|
);
|
2020-06-02 10:26:47 +03:00
|
|
|
});
|
|
|
|
|
2020-06-03 19:38:26 +03:00
|
|
|
downloadMksnapshot.on('close', code => {
|
2020-06-02 10:26:47 +03:00
|
|
|
if (code === 0) {
|
2020-06-03 19:38:26 +03:00
|
|
|
exitStatus = 'success';
|
2020-06-02 10:26:47 +03:00
|
|
|
} else {
|
2020-06-03 19:38:26 +03:00
|
|
|
exitStatus = 'error';
|
2020-06-02 10:26:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
console.info(`info: Done re-downloading mksnapshot. Status: ${exitStatus}`);
|
|
|
|
});
|
|
|
|
} else {
|
2020-06-03 19:38:26 +03:00
|
|
|
console.info(
|
|
|
|
'info: env var "ELECTRON_CUSTOM_VERSION" is already set correctly.\n(No need to re-download chromedriver or mksnapshot). Skipping.\n'
|
|
|
|
);
|
2020-06-02 10:26:47 +03:00
|
|
|
}
|