Skip to content

Commit 9f9ddb0

Browse files
committed
switch to node-fetch-native
1 parent bd7cf69 commit 9f9ddb0

File tree

4 files changed

+94
-45
lines changed

4 files changed

+94
-45
lines changed

lib/install.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ const existsAsync = fs.exists || path.exists;
1111
const versioning = require('./util/versioning.js');
1212
const napi = require('./util/napi.js');
1313
// for fetching binaries
14-
const fetch = require('node-fetch');
14+
const { fetch } = require('node-fetch-native');
15+
const { createProxy } = require('node-fetch-native/proxy');
1516
const tar = require('tar');
1617

1718
let npgVersion = 'unknown';
@@ -53,14 +54,13 @@ function place_binary(uri, targetDir, opts, callback) {
5354
process.env.http_proxy ||
5455
process.env.HTTP_PROXY ||
5556
process.env.npm_config_proxy;
56-
let agent;
57+
let proxy;
5758
if (proxyUrl) {
58-
const { HttpsProxyAgent } = require('https-proxy-agent');
59-
agent = new HttpsProxyAgent(proxyUrl);
59+
proxy = createProxy({ url: proxyUrl });
6060
log.log('download', `proxy agent configured using: "${proxyUrl}"`);
6161
}
6262

63-
fetch(sanitized, { agent })
63+
fetch(sanitized, proxy)
6464
.then((res) => {
6565
if (!res.ok) {
6666
throw new Error(`response status ${res.status} ${res.statusText} on ${sanitized}`);

package-lock.json

Lines changed: 83 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
"dependencies": {
2626
"consola": "^3.2.3",
2727
"detect-libc": "^2.0.0",
28-
"https-proxy-agent": "^7.0.5",
29-
"node-fetch": "^2.6.7",
28+
"node-fetch-native": "^1.6.4",
3029
"nopt": "^8.0.0",
3130
"semver": "^7.5.3",
3231
"tar": "^7.4.0"
@@ -39,7 +38,7 @@
3938
"eslint": "^8.57.0",
4039
"eslint-plugin-n": "^17.9.0",
4140
"mock-aws-s3": "^4.0.2",
42-
"nock": "^13.5.4",
41+
"nock": "^14.0.0-beta.19",
4342
"node-addon-api": "^8.1.0",
4443
"nyc": "^17.0.0",
4544
"tape": "^5.5.2",

test/proxy-bcrypt.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const { createUnzip } = require('zlib');
66
const os = require('os');
77

88
const tar = require('tar-fs');
9-
const { HttpsProxyAgent } = require('https-proxy-agent');
10-
const fetch = require('node-fetch');
9+
const { fetch } = require('node-fetch-native');
10+
const { createProxy } = require('node-fetch-native/proxy');
1111
const { rimraf } = require('rimraf');
1212

1313
const test = require('tape');
@@ -17,7 +17,7 @@ const proxyPort = 8124;
1717
const proxyServer = `http://localhost:${proxyPort}`;
1818

1919
// options for fetch
20-
const options = {};
20+
let options = {};
2121

2222
// the temporary download directory and file
2323
const downloadDir = `${os.tmpdir()}/npg-download`;
@@ -44,7 +44,7 @@ test('setup proxy server', (t) => {
4444
proxy.startServer({ port: proxyPort });
4545
process.env.https_proxy = process.env.http_proxy = proxyServer;
4646

47-
options.agent = new HttpsProxyAgent(proxyServer);
47+
options = createProxy({ url: proxyServer });
4848

4949
// make sure the download directory deleted then create an empty one
5050
rimraf(downloadDir).then(() => {

0 commit comments

Comments
 (0)