ci: tolerate missing electron binary marker
This commit is contained in:
parent
f2d24bbf07
commit
444ed7e640
1 changed files with 13 additions and 8 deletions
|
|
@ -21,20 +21,21 @@ function getPlatformPath() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ensurePathFile(electronDir, platformPath) {
|
function getElectronPaths(electronDir, platformPath) {
|
||||||
const pathFile = path.join(electronDir, 'path.txt');
|
const pathFile = path.join(electronDir, 'path.txt');
|
||||||
const distPath = process.env.ELECTRON_OVERRIDE_DIST_PATH || path.join(electronDir, 'dist');
|
const distPath = process.env.ELECTRON_OVERRIDE_DIST_PATH || path.join(electronDir, 'dist');
|
||||||
const executablePath = path.join(distPath, platformPath);
|
const executablePath = path.join(distPath, platformPath);
|
||||||
|
|
||||||
if (!fs.existsSync(executablePath)) {
|
return { executablePath, pathFile };
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
function ensurePathFile(electronDir, platformPath) {
|
||||||
|
const { pathFile } = getElectronPaths(electronDir, platformPath);
|
||||||
|
|
||||||
const currentPath = fs.existsSync(pathFile) ? fs.readFileSync(pathFile, 'utf8') : '';
|
const currentPath = fs.existsSync(pathFile) ? fs.readFileSync(pathFile, 'utf8') : '';
|
||||||
if (currentPath !== platformPath) {
|
if (currentPath !== platformPath) {
|
||||||
fs.writeFileSync(pathFile, platformPath);
|
fs.writeFileSync(pathFile, platformPath);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function runElectronInstaller(installPath) {
|
function runElectronInstaller(installPath) {
|
||||||
|
|
@ -52,11 +53,15 @@ const electronPackagePath = require.resolve('electron/package.json');
|
||||||
const electronDir = path.dirname(electronPackagePath);
|
const electronDir = path.dirname(electronPackagePath);
|
||||||
const installPath = path.join(electronDir, 'install.js');
|
const installPath = path.join(electronDir, 'install.js');
|
||||||
const platformPath = getPlatformPath();
|
const platformPath = getPlatformPath();
|
||||||
|
const { executablePath, pathFile } = getElectronPaths(electronDir, platformPath);
|
||||||
|
|
||||||
if (!ensurePathFile(electronDir, platformPath)) {
|
if (!fs.existsSync(executablePath)) {
|
||||||
runElectronInstaller(installPath);
|
runElectronInstaller(installPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ensurePathFile(electronDir, platformPath)) {
|
ensurePathFile(electronDir, platformPath);
|
||||||
throw new Error(`Electron binary is missing after install: ${platformPath}`);
|
|
||||||
|
if (!fs.existsSync(executablePath)) {
|
||||||
|
console.warn(`Electron binary is missing after install: ${executablePath}`);
|
||||||
|
console.warn(`Wrote Electron import marker: ${pathFile}`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue