Skip to content

Commit

Permalink
fix(rari-npm): make install faster
Browse files Browse the repository at this point in the history
Reported to vscode-ripgrep
microsoft/vscode-ripgrep#62
  • Loading branch information
fiji-flo committed Dec 20, 2024
1 parent 761cafb commit 1465576
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions rari-npm/lib/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,22 @@ export async function do_download(url, dest, opts) {
.get(url, opts, (response) => {
console.log("statusCode: " + response.statusCode);
if (response.statusCode === 302 && response.headers.location) {
response.resume(); // See https://github.com/nodejs/node/issues/47228 🤷
outFile.close();
console.log("Following redirect to: " + response.headers.location);
return do_download(response.headers.location, dest, opts).then(
resolve,
reject,
);
return do_download(response.headers.location, dest, opts)
.then(resolve)
.catch(reject);
} else if (response.statusCode !== 200) {
reject(new Error("Download failed with " + response.statusCode));
return;
return reject(
new Error("Download failed with " + response.statusCode),
);
} else {
response.pipe(outFile);
outFile.on("finish", () => {
resolve(null);
});
}

response.pipe(outFile);
outFile.on("finish", () => {
resolve(null);
});
})
.on("error", async (err) => {
await unlink(dest);
Expand Down

0 comments on commit 1465576

Please sign in to comment.