2020-10-22 01:43:52 +03:00
|
|
|
const fs = require('fs');
|
|
|
|
const path = require('path');
|
2014-11-15 12:21:07 +03:00
|
|
|
|
2020-10-22 01:43:52 +03:00
|
|
|
const pathFile = path.join(__dirname, 'path.txt');
|
2016-12-27 02:17:48 +03:00
|
|
|
|
2018-03-25 07:03:17 +03:00
|
|
|
function getElectronPath () {
|
2020-12-03 10:23:44 +03:00
|
|
|
let executablePath;
|
2018-03-25 07:03:17 +03:00
|
|
|
if (fs.existsSync(pathFile)) {
|
2020-12-03 10:23:44 +03:00
|
|
|
executablePath = fs.readFileSync(pathFile, 'utf-8');
|
|
|
|
}
|
|
|
|
if (process.env.ELECTRON_OVERRIDE_DIST_PATH) {
|
|
|
|
return path.join(process.env.ELECTRON_OVERRIDE_DIST_PATH, executablePath || 'electron');
|
|
|
|
}
|
|
|
|
if (executablePath) {
|
2020-10-22 01:43:52 +03:00
|
|
|
return path.join(__dirname, 'dist', executablePath);
|
2018-03-25 07:03:17 +03:00
|
|
|
} else {
|
2020-10-22 01:43:52 +03:00
|
|
|
throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again');
|
2018-03-25 07:03:17 +03:00
|
|
|
}
|
2016-12-27 02:17:48 +03:00
|
|
|
}
|
2018-03-25 07:03:17 +03:00
|
|
|
|
2020-10-22 01:43:52 +03:00
|
|
|
module.exports = getElectronPath();
|