1 | const fs = require('fs');
|
2 | const path = require('path');
|
3 |
|
4 | const pathFile = path.join(__dirname, 'path.txt');
|
5 |
|
6 | function getElectronPath () {
|
7 | let executablePath;
|
8 | if (fs.existsSync(pathFile)) {
|
9 | executablePath = fs.readFileSync(pathFile, 'utf-8');
|
10 | }
|
11 | if (process.env.ELECTRON_OVERRIDE_DIST_PATH) {
|
12 | return path.join(process.env.ELECTRON_OVERRIDE_DIST_PATH, executablePath || 'electron');
|
13 | }
|
14 | if (executablePath) {
|
15 | return path.join(__dirname, 'dist', executablePath);
|
16 | } else {
|
17 | throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again');
|
18 | }
|
19 | }
|
20 |
|
21 | module.exports = getElectronPath();
|