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
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -43,3 +43,8 @@
|
||||||
node_modules/
|
node_modules/
|
||||||
SHASUMS256.txt
|
SHASUMS256.txt
|
||||||
**/package-lock.json
|
**/package-lock.json
|
||||||
|
**/yarn.lock
|
||||||
|
|
||||||
|
# npm package
|
||||||
|
/npm/dist
|
||||||
|
/npm/path.txt
|
|
@ -85,3 +85,13 @@ This environment variable will not work if the `crashReporter` is started.
|
||||||
Shows the Windows's crash dialog when Electron crashes.
|
Shows the Windows's crash dialog when Electron crashes.
|
||||||
|
|
||||||
This environment variable will not work if the `crashReporter` is started.
|
This environment variable will not work if the `crashReporter` is started.
|
||||||
|
|
||||||
|
### `ELECTRON_OVERRIDE_DIST_PATH`
|
||||||
|
|
||||||
|
When running from the `electron` package, this variable tells
|
||||||
|
the `electron` command to use the specified build of Electron instead of
|
||||||
|
the one downloaded by `npm install`. Usage:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
export ELECTRON_OVERRIDE_DIST_PATH=/Users/username/projects/electron/out/D
|
||||||
|
```
|
||||||
|
|
16
npm/index.js
16
npm/index.js
|
@ -3,8 +3,16 @@ var path = require('path')
|
||||||
|
|
||||||
var pathFile = path.join(__dirname, 'path.txt')
|
var pathFile = path.join(__dirname, 'path.txt')
|
||||||
|
|
||||||
if (fs.existsSync(pathFile)) {
|
function getElectronPath () {
|
||||||
module.exports = path.join(__dirname, fs.readFileSync(pathFile, 'utf-8'))
|
if (fs.existsSync(pathFile)) {
|
||||||
} else {
|
var executablePath = fs.readFileSync(pathFile, 'utf-8')
|
||||||
throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')
|
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) {
|
switch (platform) {
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return 'dist/Electron.app/Contents/MacOS/Electron'
|
return 'Electron.app/Contents/MacOS/Electron'
|
||||||
case 'freebsd':
|
case 'freebsd':
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return 'dist/electron'
|
return 'electron'
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return 'dist/electron.exe'
|
return 'electron.exe'
|
||||||
default:
|
default:
|
||||||
throw new Error('Electron builds are not available on platform: ' + platform)
|
throw new Error('Electron builds are not available on platform: ' + platform)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue