Skip to content

Commit

Permalink
fix: removed download progress
Browse files Browse the repository at this point in the history
  • Loading branch information
charlypa committed Oct 31, 2023
1 parent 900efdf commit 3051861
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions src-build/downloadNodeBinary.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,32 +52,18 @@ async function downloadNodeBinary(platform, arch, maxRetries = 3) {
}

const writer = fs.createWriteStream(outputPath);
const { data, headers } = await axios({
const { data } = await axios({
url: asset.browser_download_url,
method: 'GET',
responseType: 'stream',
timeout: 10000
});

const str = progress({
length: headers['content-length'],
time: 100
});

let lastLoggedPercentage = -1;
str.on('progress', progress => {
const percentage = Math.round(progress.percentage);
if (percentage !== lastLoggedPercentage && percentage % 10 === 0) {
console.log(`Downloading... ${percentage}%`);
lastLoggedPercentage = percentage;
}
});

data.pipe(str).pipe(writer);
data.pipe(writer);

return new Promise((resolve, reject) => {
writer.on('finish', () => {
console.log('\nDownload completed:', asset.name);
console.log('Download completed:', asset.name);
resolve(asset.name);
});
writer.on('error', err => {
Expand All @@ -97,6 +83,7 @@ async function downloadNodeBinary(platform, arch, maxRetries = 3) {
}
}


/**
* Extracts a tar archive file to the specified output directory.
* @param {string} inputFile - The path of the tar archive file to be extracted.
Expand Down Expand Up @@ -246,4 +233,4 @@ console.log(args);
const platformDetails = (args.length === 1) ? JSON.parse(args[0]) : getPlatformDetails();
console.log(platformDetails);

await copyLatestNodeForBuild(platformDetails.platform, platformDetails.arch);
await copyLatestNodeForBuild(platformDetails.platform, platformDetails.arch);

0 comments on commit 3051861

Please sign in to comment.