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