Skip to content

Commit

Permalink
add TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Jun 30, 2024
1 parent aefe24c commit d7ec7e8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ function place_binary(uri, targetDir, opts, callback) {
process.env.npm_config_proxy;
let agent;
if (proxyUrl) {
// TODO: replace with undici's ProxyAgent
const { HttpsProxyAgent } = require('https-proxy-agent');
agent = new HttpsProxyAgent(proxyUrl);
log.http('download', 'proxy agent configured using: "%s"', proxyUrl);
}

// TODO: use node's built-in fetch
fetch(sanitized, { agent })
.then((res) => {
if (!res.ok) {
Expand Down
2 changes: 2 additions & 0 deletions test/proxy-bcrypt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ test('setup proxy server', (t) => {
proxy.startServer({ port: proxyPort });
process.env.https_proxy = process.env.http_proxy = proxyServer;

// TODO: replace with undici's ProxyAgent
options.agent = new HttpsProxyAgent(proxyServer);

// make sure the download directory deleted then create an empty one
Expand All @@ -65,6 +66,7 @@ test('verify node fetch with a proxy successfully downloads bcrypt pre-built', (
const url = 'https://github.com/kelektiv/node.bcrypt.js/releases/download/v5.0.1/bcrypt_lib-v5.0.1-napi-v3-linux-x64-glibc.tar.gz';

async function getBcrypt() {
// TODO: use node's built-in fetch
const res = await fetch(url, options);
if (res.status !== 200) {
throw new Error(`fetch got error ${res.status}`);
Expand Down

0 comments on commit d7ec7e8

Please sign in to comment.