@electron/get
- Version 3.1.0
- Published
- 126 kB
- 7 dependencies
- MIT license
Install
npm i @electron/get
yarn add @electron/get
pnpm add @electron/get
Overview
Utility for downloading artifacts from different versions of Electron
Index
Functions
Classes
Interfaces
Enums
Type Aliases
Functions
function download
download: ( version: string, options?: ElectronDownloadRequestOptions) => Promise<string>;
Downloads the Electron binary for a specific version and returns an absolute path to a ZIP file.
Parameter version
The version of Electron you want to download (e.g.
31.0.0
)Parameter options
Options to customize the download behavior
Returns
An absolute path to the downloaded ZIP file Download Electron
function downloadArtifact
downloadArtifact: ( artifactDetails: | ElectronPlatformArtifactDetailsWithDefaults | ElectronGenericArtifactDetails) => Promise<string>;
Downloads an artifact from an Electron release and returns an absolute path to the downloaded file.
Each release of Electron comes with artifacts, many of which are platform/arch-specific (e.g.
ffmpeg-v31.0.0-darwin-arm64.zip
) and others that are generic (e.g.SHASUMS256.txt
).Parameter artifactDetails
The information required to download the artifact Download Artifact
function getHostArch
getHostArch: () => string;
Generates an architecture name that would be used in an Electron or Node.js download file name from the
process
module information.Utility
function initializeProxy
initializeProxy: () => void;
Initializes a third-party proxy module for HTTP(S) requests. Call this function before using the download and downloadArtifact APIs if you need proxy support.
If the
ELECTRON_GET_USE_PROXY
environment variable is set totrue
, this function will be called automatically for@electron/get
requests.Utility
Example 1
export GLOBAL_AGENT_HTTPS_PROXY="$HTTPS_PROXY"See Also
`global-agent` documentation for available environment variables.
Classes
class GotDownloader
class GotDownloader implements Downloader<GotDownloaderOptions> {}
Default Downloader implemented with `got`. Downloader
method download
download: ( url: string, targetFilePath: string, options?: GotDownloaderOptions) => Promise<void>;
Interfaces
interface Downloader
interface Downloader<T> {}
Generic interface for the artifact downloader library. The default implementation is GotDownloader, but any custom downloader can be passed to
@electron/get
via the ElectronDownloadRequestOptions.downloader option.
method download
download: (url: string, targetFilePath: string, options: T) => Promise<void>;
Download an artifact from an arbitrary URL to a file path on system
Parameter url
URL of the file to download
Parameter targetFilePath
Filesystem path to download the artifact to (including the file name)
Parameter options
Options to pass to the downloader
interface ElectronDownloadRequestOptions
interface ElectronDownloadRequestOptions {}
Download Electron
property cacheMode
cacheMode?: ElectronDownloadCacheMode;
Controls the cache read and write behavior.
When set to either ReadOnly or Bypass, the caller is responsible for cleaning up the returned file path once they are done using it (e.g. via
fs.remove(path.dirname(pathFromElectronGet))
).When set to either WriteOnly or ReadWrite (the default), the caller should not move or delete the file path that is returned as the path points directly to the disk cache.
This option cannot be used in conjunction with ElectronDownloadRequestOptions.force.
property cacheRoot
cacheRoot?: string;
The directory that caches Electron artifact downloads.
property checksums
checksums?: Record<string, string>;
Provides checksums for the artifact as strings. Can be used if you already know the checksums of the Electron artifact you are downloading and want to skip the checksum file download without skipping the checksum validation.
This should be an object whose keys are the file names of the artifacts and the values are their respective SHA256 checksums.
Example 1
{"electron-v4.0.4-linux-x64.zip": "877617029f4c0f2b24f3805a1c3554ba166fda65c4e88df9480ae7b6ffa26a22"}
property downloader
downloader?: Downloader<DownloadOptions>;
A custom Downloader class used to download artifacts. Defaults to the built-in GotDownloader.
property downloadOptions
downloadOptions?: DownloadOptions;
Options passed to the downloader module.
See Also
GotDownloaderOptions for options for the default GotDownloader.
property force
force?: boolean;
Whether to download an artifact regardless of whether it's in the cache directory.
Deprecated
This option is deprecated and directly maps to `cacheMode: ElectronDownloadCacheMode.WriteOnly`
property mirrorOptions
mirrorOptions?: MirrorOptions;
Options related to specifying an artifact mirror.
property tempDirectory
tempDirectory?: string;
A temporary directory for downloads. It is used before artifacts are put into cache.
property unsafelyDisableChecksums
unsafelyDisableChecksums?: boolean;
When set to
true
, disables checking that the artifact download completed successfully with the correct payload.
interface MirrorOptions
interface MirrorOptions {}
Options for specifying an alternative download mirror for Electron.
Utility
Example 1
To download the Electron v4.0.4 release for x64 Linux from https://github.com/electron/electron/releases/download/v4.0.4/electron-v4.0.4-linux-x64.zip
const opts = {mirror: 'https://github.com/electron/electron/releases/download',customDir: 'v4.0.4',customFilename: 'electron-v4.0.4-linux-x64.zip',}
property customDir
customDir?: string;
The name of the directory to download from, often scoped by version number e.g 'v4.0.4'
property customFilename
customFilename?: string;
The name of the asset to download, e.g 'electron-v4.0.4-linux-x64.zip'
property customVersion
customVersion?: string;
The version of the asset to download, e.g '4.0.4'
property mirror
mirror?: string;
The base URL of the mirror to download from. e.g https://github.com/electron/electron/releases/download
property nightly_mirror
nightly_mirror?: string;
See Also
Deprecated
property nightlyMirror
nightlyMirror?: string;
The mirror URL for [
electron-nightly
](https://npmjs.com/package/electron-nightly), which lives in a separate npm package.
property resolveAssetURL
resolveAssetURL?: (opts: DownloadOptions) => Promise<string>;
A function allowing customization of the url returned from getArtifactRemoteURL().
Enums
enum ElectronDownloadCacheMode
enum ElectronDownloadCacheMode { ReadWrite = 0, ReadOnly = 1, WriteOnly = 2, Bypass = 3,}
member Bypass
Bypass = 3
Bypasses the cache completely, neither reads from nor writes to the cache
member ReadOnly
ReadOnly = 1
Reads from the cache if present Will **not** write back to the cache after fetching missing artifact
member ReadWrite
ReadWrite = 0
Reads from the cache if present Writes to the cache after fetch if not present
member WriteOnly
WriteOnly = 2
Skips reading from the cache Will write back into the cache, overwriting anything currently in the cache after fetch
Type Aliases
type DownloadOptions
type DownloadOptions = any;
Custom downloaders can implement any set of options. Downloader
type ElectronGenericArtifactDetails
type ElectronGenericArtifactDetails = { isGeneric: true;} & ElectronDownloadRequest & ElectronDownloadRequestOptions;
Options to download a generic (i.e. platform and architecture-agnostic) Electron artifact. Contains all options from ElectronDownloadRequestOptions, but specifies a
version
andartifactName
for the artifact to download.Download Artifact
type ElectronPlatformArtifactDetailsWithDefaults
type ElectronPlatformArtifactDetailsWithDefaults = Omit< ElectronPlatformArtifactDetails, 'platform' | 'arch'> & { /** * The target artifact platform. These are Node-style platform names, for example: * * `win32` * * `darwin` * * `linux` * * @see Node.js {@link https://nodejs.org/api/process.html#processplatform | process.platform} docs */ platform?: string; /** * The target artifact architecture. These are Node-style architecture names, for example: * * `ia32` * * `x64` * * `armv7l` * * @see Node.js {@link https://nodejs.org/api/process.html#processarch | process.arch} docs */ arch?: string;};
Options to download a platform and architecture-specific Electron artifact. Contains all options from ElectronDownloadRequestOptions, but specifies a
version
andartifactName
for the artifact to download.If
platform
andarch
are omitted, they will be inferred using the host system platform and architecture.Download Artifact
type GotDownloaderOptions
type GotDownloaderOptions = GotOptions & { isStream?: true;} & { /** * if defined, triggers every time `got`'s * {@link https://github.com/sindresorhus/got/tree/v11.8.5?tab=readme-ov-file#downloadprogress | `downloadProgress``} event callback is triggered. */ getProgressCallback?: (progress: GotProgress) => Promise<void>; /** * if `true`, disables the console progress bar (setting the `ELECTRON_GET_NO_PROGRESS` * environment variable to a non-empty value also does this). */ quiet?: boolean;};
Options for the default [
got
](https://github.com/sindresorhus/got) Downloader implementation.Downloader
See Also
`got#options` for possible keys/values.
Package Files (6)
Dependencies (7)
Dev Dependencies (19)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@electron/get
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@electron/get)
- HTML<a href="https://www.jsdocs.io/package/@electron/get"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3352 ms. - Missing or incorrect documentation? Open an issue for this package.