X Tutup
Skip to content

Commit 2e5cb93

Browse files
MarshallOfSoundcodebytere
authored andcommitted
Provide an easy way to use a local build of Electron (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
1 parent cfd91a3 commit 2e5cb93

File tree

4 files changed

+31
-8
lines changed

4 files changed

+31
-8
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,9 @@
4242
/vendor/python_26/
4343
node_modules/
4444
SHASUMS256.txt
45-
**/package-lock.json
45+
**/package-lock.json
46+
**/yarn.lock
47+
48+
# npm package
49+
/npm/dist
50+
/npm/path.txt

docs/api/environment-variables.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,13 @@ This environment variable will not work if the `crashReporter` is started.
8585
Shows the Windows's crash dialog when Electron crashes.
8686

8787
This environment variable will not work if the `crashReporter` is started.
88+
89+
### `ELECTRON_OVERRIDE_DIST_PATH`
90+
91+
When running from the `electron` package, this variable tells
92+
the `electron` command to use the specified build of Electron instead of
93+
the one downloaded by `npm install`. Usage:
94+
95+
```sh
96+
export ELECTRON_OVERRIDE_DIST_PATH=/Users/username/projects/electron/out/D
97+
```

npm/index.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@ var path = require('path')
33

44
var pathFile = path.join(__dirname, 'path.txt')
55

6-
if (fs.existsSync(pathFile)) {
7-
module.exports = path.join(__dirname, fs.readFileSync(pathFile, 'utf-8'))
8-
} else {
9-
throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')
6+
function getElectronPath () {
7+
if (fs.existsSync(pathFile)) {
8+
var executablePath = fs.readFileSync(pathFile, 'utf-8')
9+
if (process.env.ELECTRON_OVERRIDE_DIST_PATH) {
10+
return path.join(process.env.ELECTRON_OVERRIDE_DIST_PATH, executablePath)
11+
}
12+
return path.join(__dirname, 'dist', executablePath)
13+
} else {
14+
throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')
15+
}
1016
}
17+
18+
module.exports = getElectronPath()

npm/install.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ function getPlatformPath () {
5252

5353
switch (platform) {
5454
case 'darwin':
55-
return 'dist/Electron.app/Contents/MacOS/Electron'
55+
return 'Electron.app/Contents/MacOS/Electron'
5656
case 'freebsd':
5757
case 'linux':
58-
return 'dist/electron'
58+
return 'electron'
5959
case 'win32':
60-
return 'dist/electron.exe'
60+
return 'electron.exe'
6161
default:
6262
throw new Error('Electron builds are not available on platform: ' + platform)
6363
}

0 commit comments

Comments
 (0)
X Tutup