Install: log proxy use, if any, to aid with debugging

This commit is contained in:
Lovell Fuller
2022-12-06 19:35:47 +00:00
parent 9d760f3958
commit def99a294a
3 changed files with 14 additions and 7 deletions

View File

@@ -18,7 +18,7 @@ function env (key) {
return process.env[key];
}
module.exports = function () {
module.exports = function (log) {
try {
const proxy = new url.URL(proxies.map(env).find(is.string));
const tunnel = proxy.protocol === 'https:'
@@ -27,6 +27,7 @@ module.exports = function () {
const proxyAuth = proxy.username && proxy.password
? `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`
: null;
log(`Via proxy ${proxy.protocol}://${proxy.hostname}:${proxy.port} ${proxyAuth ? 'with' : 'no'} credentials`);
return tunnel({
proxy: {
port: Number(proxy.port),