1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
Description: use another fetch to avoid unavailable make-fetch-happen
Author: Jérémy Lal <kapouer@melix.org>
Forwarded: not-needed
Last-Update: 2021-12-01
--- a/lib/download.js
+++ b/lib/download.js
@@ -1,4 +1,4 @@
-const fetch = require('make-fetch-happen')
+const fetch = require('node-fetch')
const { promises: fs } = require('graceful-fs')
const log = require('./log')
@@ -9,14 +9,22 @@
headers: {
'User-Agent': `node-gyp v${gyp.version} (node ${process.version})`,
Connection: 'keep-alive'
- },
- proxy: gyp.opts.proxy,
- noProxy: gyp.opts.noproxy
+ }
+ }
+ if (gyp.opts.proxy) {
+ let proxy=true
+ if (gyp.opts.noproxy) {
+ let tmp = typeof gyp.opts.noproxy == 'string' ? gyp.opts.noproxy.split(/,\s*/) : gyp.opts.noproxy
+ if (tmp.includes(url)) proxy = false;
+ }
+ if (proxy) {
+ const {HttpsProxyAgent} = require('https-proxy-agent');
+ requestOpts.agent = new HttpsProxyAgent(gyp.opts.proxy);
+ }
}
- const cafile = gyp.opts.cafile
- if (cafile) {
- requestOpts.ca = await readCAFile(cafile)
+ if (gyp.opts.cafile) {
+ console.error('cafile option not implemented here, use NODE_EXTRA_CA_CERTS variable instead');
}
const res = await fetch(url, requestOpts)
|