pulsar/script/redownload-electron-bins.js

51 lines
1.6 KiB
JavaScript
Raw Normal View History

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;
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` +
`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'
);
const downloadChromedriver = spawn('node', [downloadChromedriverPath]);
const downloadMksnapshot = spawn('node', [downloadMksnapshotPath]);
var exitStatus;
2020-06-03 19:38:26 +03:00
downloadChromedriver.on('close', code => {
if (code === 0) {
2020-06-03 19:38:26 +03:00
exitStatus = 'success';
} else {
2020-06-03 19:38:26 +03:00
exitStatus = 'error';
}
2020-06-03 19:38:26 +03:00
console.info(
`info: Done re-downloading chromedriver. Status: ${exitStatus}`
);
});
2020-06-03 19:38:26 +03:00
downloadMksnapshot.on('close', code => {
if (code === 0) {
2020-06-03 19:38:26 +03:00
exitStatus = 'success';
} else {
2020-06-03 19:38:26 +03:00
exitStatus = 'error';
}
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'
);
}