-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
26 lines (22 loc) · 920 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const fs = require('fs');
const path = require('path');
const pathFile = path.join(__dirname, 'path.txt');
function getElectronPath() {
if (fs.existsSync(pathFile)) {
const executablePath = fs.readFileSync(pathFile, 'utf-8');
if (process.env.ELECTRON_OVERRIDE_DIST_PATH) {
return path.join(process.env.ELECTRON_OVERRIDE_DIST_PATH, executablePath)
}
return path.join(__dirname, 'dist', executablePath)
} else {
throw new Error('Electronite failed to install correctly, please delete node_modules/electronite and try installing again')
}
}
// TRICKY: Return the built-in electron package when running in the electron environment.
// Otherwise, return the path so we can run the binary.
// This enables using require("electronite") within the code.
try {
module.exports = require('electron');
} catch (e) {
module.exports = getElectronPath();
}