From 84592a2d8b46602f752f93018f38f8e90dc19dcf Mon Sep 17 00:00:00 2001 From: Adriano Raiano Date: Mon, 8 Feb 2021 17:27:24 +0100 Subject: [PATCH] introduce optional HTTPS_PROXY environment variable --- CHANGELOG.md | 5 +++++ package.json | 1 + request.js | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9f867b..4752db8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. Project versioning adheres to [Semantic Versioning](http://semver.org/). Change log format is based on [Keep a Changelog](http://keepachangelog.com/). +## [7.6.12](https://github.com/locize/locize-cli/compare/v7.6.11...v7.6.12) - 2021-02-08 + +- introduce optional HTTPS_PROXY environment variable + + ## [7.6.11](https://github.com/locize/locize-cli/compare/v7.6.10...v7.6.11) - 2021-02-08 - --get-path param for sync command diff --git a/package.json b/package.json index e157a27..331b278 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "flat": "5.0.2", "fluent_conv": "3.1.0", "gettext-converter": "1.0.6", + "https-proxy-agent": "5.0.0", "ini": "2.0.0", "js-yaml": "4.0.0", "laravelphp": "2.0.3", diff --git a/request.js b/request.js index d9c1fd1..24cc16d 100644 --- a/request.js +++ b/request.js @@ -1,7 +1,11 @@ const package = require('./package.json'); const fetch = require('node-fetch'); +const HttpsProxyAgent = require('https-proxy-agent'); +const httpProxy = process.env.http_proxy || process.env.HTTP_PROXY || process.env.https_proxy || process.env.HTTPS_PROXY; module.exports = (url, options, callback) => { + if (httpProxy) options.agent = new HttpsProxyAgent(httpProxy); + options.headers = options.headers || {}; options.headers['User-Agent'] = `${package.name}/v${package.version} (node/${process.version}; ${process.platform} ${process.arch})`; options.headers['X-User-Agent'] = options.headers['User-Agent'];