feat: allow path override with --ignore-scripts (#25377)
If you --ignore-scripts when installing electron currently, it'll fail to write the path.txt file and thus fail to use the override dist path. Open to other solutions - just hoping to be able to use a prebuilt electron binary with the default package without having to muck around with it installing an unused version.
This commit is contained in:
parent
b37982987a
commit
5521f8acca
1 changed files with 7 additions and 4 deletions
11
npm/index.js
11
npm/index.js
|
@ -4,11 +4,14 @@ const path = require('path');
|
||||||
const pathFile = path.join(__dirname, 'path.txt');
|
const pathFile = path.join(__dirname, 'path.txt');
|
||||||
|
|
||||||
function getElectronPath () {
|
function getElectronPath () {
|
||||||
|
let executablePath;
|
||||||
if (fs.existsSync(pathFile)) {
|
if (fs.existsSync(pathFile)) {
|
||||||
const executablePath = fs.readFileSync(pathFile, 'utf-8');
|
executablePath = fs.readFileSync(pathFile, 'utf-8');
|
||||||
if (process.env.ELECTRON_OVERRIDE_DIST_PATH) {
|
}
|
||||||
return path.join(process.env.ELECTRON_OVERRIDE_DIST_PATH, executablePath);
|
if (process.env.ELECTRON_OVERRIDE_DIST_PATH) {
|
||||||
}
|
return path.join(process.env.ELECTRON_OVERRIDE_DIST_PATH, executablePath || 'electron');
|
||||||
|
}
|
||||||
|
if (executablePath) {
|
||||||
return path.join(__dirname, 'dist', executablePath);
|
return path.join(__dirname, 'dist', executablePath);
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again');
|
throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again');
|
||||||
|
|
Loading…
Reference in a new issue