Skip to content

Commit

Permalink
deps: fetch build artefacts using a proxy where necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsgruk committed Nov 4, 2023
1 parent e8ab1dc commit f3e4fd5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion deps/download.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const https = require('https');
const { HttpsProxyAgent } = require('https-proxy-agent');
const fs = require('fs');
const path = require('path');
const crypto = require('crypto');
Expand Down Expand Up @@ -35,7 +36,16 @@ async function main() {

function download() {
console.log(`downloading ${URL}`);
https.get(URL, async (res) => {

let options = {};
if (process.env.HTTPS_PROXY != undefined) {
options.agent = new HttpsProxyAgent(process.env.HTTPS_PROXY);
}
if (process.env.https_proxy != undefined) {
options.agent = new HttpsProxyAgent(process.env.https_proxy);
}

https.get(URL, options, async (res) => {
const out = fs.createWriteStream(tmpFile);

const hash = crypto.createHash('sha256');
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
],
"dependencies": {
"bindings": "^1.5.0",
"https-proxy-agent": "^7.0.2",
"tar": "^6.1.0"
},
"devDependencies": {
Expand Down

0 comments on commit f3e4fd5

Please sign in to comment.