Provide an easy way to use a local build of Electron (#12426)
* Provide an easy way to use a local build of Electron For instance from ~/projects/electron/out/D * document ELECTRON_OVERRIDE_DIST_PATH * Make the linter happy * Tweak ELECTRON_OVERRIDE_DIST_PATH docs
This commit is contained in:
parent
cfd91a3b56
commit
2e5cb930de
4 changed files with 31 additions and 8 deletions
16
npm/index.js
16
npm/index.js
|
@ -3,8 +3,16 @@ var path = require('path')
|
|||
|
||||
var pathFile = path.join(__dirname, 'path.txt')
|
||||
|
||||
if (fs.existsSync(pathFile)) {
|
||||
module.exports = path.join(__dirname, fs.readFileSync(pathFile, 'utf-8'))
|
||||
} else {
|
||||
throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')
|
||||
function getElectronPath () {
|
||||
if (fs.existsSync(pathFile)) {
|
||||
var 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('Electron failed to install correctly, please delete node_modules/electron and try installing again')
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = getElectronPath()
|
||||
|
|
|
@ -52,12 +52,12 @@ function getPlatformPath () {
|
|||
|
||||
switch (platform) {
|
||||
case 'darwin':
|
||||
return 'dist/Electron.app/Contents/MacOS/Electron'
|
||||
return 'Electron.app/Contents/MacOS/Electron'
|
||||
case 'freebsd':
|
||||
case 'linux':
|
||||
return 'dist/electron'
|
||||
return 'electron'
|
||||
case 'win32':
|
||||
return 'dist/electron.exe'
|
||||
return 'electron.exe'
|
||||
default:
|
||||
throw new Error('Electron builds are not available on platform: ' + platform)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue