Home

Awesome

@electron/get

Download Electron release artifacts

CircleCI NPM package

Usage

For full API details, see the API documentation.

Simple: Downloading an Electron Binary ZIP

import { download } from '@electron/get';

// NB: Use this syntax within an async function, Node does not have support for
//     top-level await as of Node 12.
const zipFilePath = await download('4.0.4');

Advanced: Downloading a macOS Electron Symbol File

import { downloadArtifact } from '@electron/get';

// NB: Use this syntax within an async function, Node does not have support for
//     top-level await as of Node 12.
const zipFilePath = await downloadArtifact({
  version: '4.0.4',
  platform: 'darwin',
  artifactName: 'electron',
  artifactSuffix: 'symbols',
  arch: 'x64',
});

Specifying a mirror

To specify another location to download Electron assets from, the following options are available:

Anatomy of a download URL, in terms of mirrorOptions:

https://github.com/electron/electron/releases/download/v4.0.4/electron-v4.0.4-linux-x64.zip
|                                                     |       |                           |
-------------------------------------------------------       -----------------------------
                        |                                                   |
              mirror / nightlyMirror                  |    |         customFilename
                                                       ------
                                                         ||
                                                      customDir

Example:

import { download } from '@electron/get';

const zipFilePath = await download('4.0.4', {
  mirrorOptions: {
    mirror: 'https://mirror.example.com/electron/',
    customDir: 'custom',
    customFilename: 'unofficial-electron-linux.zip'
  }
});
// Will download from https://mirror.example.com/electron/custom/unofficial-electron-linux.zip

const nightlyZipFilePath = await download('8.0.0-nightly.20190901', {
  mirrorOptions: {
    nightlyMirror: 'https://nightly.example.com/',
    customDir: 'nightlies',
    customFilename: 'nightly-linux.zip'
  }
});
// Will download from https://nightly.example.com/nightlies/nightly-linux.zip

customDir can have the placeholder {{ version }}, which will be replaced by the version specified (without the leading v). For example:

const zipFilePath = await download('4.0.4', {
  mirrorOptions: {
    mirror: 'https://mirror.example.com/electron/',
    customDir: 'version-{{ version }}',
    platform: 'linux',
    arch: 'x64'
  }
});
// Will download from https://mirror.example.com/electron/version-4.0.4/electron-v4.0.4-linux-x64.zip

Using environment variables for mirror options

Mirror options can also be specified via the following environment variables:

Overriding the version downloaded

The version downloaded can be overriden by setting the ELECTRON_CUSTOM_VERSION environment variable. Setting this environment variable will override the version passed in to download or downloadArtifact.

How It Works

This module downloads Electron to a known place on your system and caches it so that future requests for that asset can be returned instantly. The cache locations are:

By default, the module uses got as the downloader. As a result, you can use the same options via downloadOptions.

Progress Bar

By default, a progress bar is shown when downloading an artifact for more than 30 seconds. To disable, set the ELECTRON_GET_NO_PROGRESS environment variable to any non-empty value, or set quiet to true in downloadOptions. If you need to monitor progress yourself via the API, set getProgressCallback in downloadOptions, which has the same function signature as got's downloadProgress event callback.

Proxies

Downstream packages should utilize the initializeProxy function to add HTTP(S) proxy support. If the environment variable ELECTRON_GET_USE_PROXY is set, it is called automatically.

Debug

debug is used to display logs and messages. Set the DEBUG=@electron/get* environment variable to log additional debug information from this module.