Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Commit

Permalink
use downloadOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomoreno committed Jan 25, 2021
1 parent 01f554c commit 9bc9b52
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,25 @@ async function download(opts) {
}

const artifactName = opts.assetName ? opts.assetName : "electron";

let downloadOpts = {
const electronOptions = {
version: opts.version,
platform: opts.platform,
arch,
artifactName,
artifactSuffix: opts.artifactSuffix,
token: opts.token,
downloadOptions: {
getProgressCallback: (progress) => {
if (bar) bar.update(progress.percent);
},
},
};

if (opts.token) {
electronOptions.downloadOptions.headers = {
authorization: `token ${opts.token}`,
};
}

bar = new ProgressBar(
`Downloading ${artifactName}: [:bar] :percent ETA: :eta seconds `,
{
Expand All @@ -60,17 +64,14 @@ async function download(opts) {
);

if (opts.mirror) {
downloadOpts = {
...downloadOpts,
mirrorOptions: { mirror: opts.mirror },
unsafelyDisableChecksums: true,
};
electronOptions.mirrorOptions = { mirror: opts.mirror };
electronOptions.unsafelyDisableChecksums = true;
}

const start = new Date();
bar.start = start;

return await downloadArtifact(downloadOpts);
return await downloadArtifact(electronOptions);
}

function downloadStream(opts) {
Expand Down

0 comments on commit 9bc9b52

Please sign in to comment.