From b4658efae582c6ab0026bcb30c38f49decd664ad Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Wed, 4 Mar 2020 05:44:04 -0800 Subject: [PATCH] docs: add custom dir placeholder explainer to installation guide (#22491) * docs: add custom dir placeholder explainer to installation docs * docs: provide a more concrete example of using ELECTRON_CUSTOM_DIR --- docs/tutorial/installation.md | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/docs/tutorial/installation.md b/docs/tutorial/installation.md index 69e697a8cb97..6597e9c6f618 100644 --- a/docs/tutorial/installation.md +++ b/docs/tutorial/installation.md @@ -56,19 +56,33 @@ can do so by either providing a mirror or an existing cache directory. #### Mirror You can use environment variables to override the base URL, the path at which to -look for Electron binaries, and the binary filename. The url used by `@electron/get` +look for Electron binaries, and the binary filename. The URL used by `@electron/get` is composed as follows: -```plaintext +```javascript url = ELECTRON_MIRROR + ELECTRON_CUSTOM_DIR + '/' + ELECTRON_CUSTOM_FILENAME ``` -For instance, to use the China mirror: +For instance, to use the China CDN mirror: -```plaintext +```shell ELECTRON_MIRROR="https://cdn.npm.taobao.org/dist/electron/" ``` +By default, `ELECTRON_CUSTOM_DIR` is set to `v$VERSION`. To change the format, +use the `{{ version }}` placeholder. For example, `version-{{ version }}` +resolves to `version-5.0.0`, `{{ version }}` resolves to `5.0.0`, and +`v{{ version }}` is equivalent to the default. As a more concrete example, to +use the China non-CDN mirror: + +```shell +ELECTRON_MIRROR="https://npm.taobao.org/mirrors/electron/" +ELECTRON_CUSTOM_DIR="{{ version }}" +``` + +The above configuration will download from URLs such as +`https://npm.taobao.org/mirrors/electron/8.0.0/electron-v8.0.0-linux-x64.zip`. + #### Cache Alternatively, you can override the local cache. `@electron/get` will cache downloaded binaries in a local directory to not stress your network. You can use