diff --git a/.gitignore b/.gitignore index 415b319a3..bbfe5148b 100644 --- a/.gitignore +++ b/.gitignore @@ -42,4 +42,9 @@ /vendor/python_26/ node_modules/ SHASUMS256.txt -**/package-lock.json +**/package-lock.json +**/yarn.lock + +# npm package +/npm/dist +/npm/path.txt \ No newline at end of file diff --git a/docs/api/environment-variables.md b/docs/api/environment-variables.md index a9459ff05..72f75e6b8 100644 --- a/docs/api/environment-variables.md +++ b/docs/api/environment-variables.md @@ -85,3 +85,13 @@ This environment variable will not work if the `crashReporter` is started. Shows the Windows's crash dialog when Electron crashes. 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 +``` diff --git a/npm/index.js b/npm/index.js index eb480b9e0..b33c9b493 100644 --- a/npm/index.js +++ b/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() diff --git a/npm/install.js b/npm/install.js index 8cb9ed881..41052ac07 100755 --- a/npm/install.js +++ b/npm/install.js @@ -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) }