From a59dc56fa6ddcb3d9f1fb76a70b01bcdade0e6a7 Mon Sep 17 00:00:00 2001 From: Joshua Westerheide Date: Fri, 3 May 2019 19:17:15 +0200 Subject: [PATCH] feat: add env variable to skip binary download on npm install (#17627) * feat: add env variable to skip binary download on npm install * docs: add "Skip binary download" section to install tutorial --- docs/tutorial/installation.md | 11 +++++++++++ npm/install.js | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/docs/tutorial/installation.md b/docs/tutorial/installation.md index 5eeb89911b72..3aaba70d369a 100644 --- a/docs/tutorial/installation.md +++ b/docs/tutorial/installation.md @@ -97,6 +97,17 @@ a text file. A typical cache might look like this: ├── SHASUMS256.txt-1.8.2-beta.3 ``` +## Skip binary download +When installing the `electron` NPM package, it automatically downloads the electron binary. + +This can sometimes be unnecessary, e.g. in a CI environment, when testing another component. + +To prevent the binary from being downloaded when you install all npm dependencies you can set the environment variable `ELECTRON_SKIP_BINARY_DOWNLOAD`. +E.g.: +```sh +ELECTRON_SKIP_BINARY_DOWNLOAD=1 npm install +``` + ## Troubleshooting When running `npm install electron`, some users occasionally encounter diff --git a/npm/install.js b/npm/install.js index 3f59ce15d22b..05bdab0bdab0 100755 --- a/npm/install.js +++ b/npm/install.js @@ -15,6 +15,10 @@ try { // do nothing } +if (process.env.ELECTRON_SKIP_BINARY_DOWNLOAD) { + process.exit(0) +} + var platformPath = getPlatformPath() var electronPath = process.env.ELECTRON_OVERRIDE_DIST_PATH || path.join(__dirname, 'dist', platformPath)