Skip to content

Commit 9d8c8cd

Browse files
committed
lib/octokit: use https-proxy-agent only if a proxy is configured
1 parent 74f2473 commit 9d8c8cd

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/lib/octokit/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
import {Octokit as Core} from '@octokit/core'
22
import {paginateRest} from '@octokit/plugin-paginate-rest'
33
import {legacyRestEndpointMethods} from '@octokit/plugin-rest-endpoint-methods'
4-
const HttpsProxyAgent = require("https-proxy-agent")
4+
5+
const HttpsProxyAgent = require('https-proxy-agent')
56

67
const DEFAULTS = {
78
baseUrl: getApiBaseUrl()
89
}
910

11+
const httpProxy = process.env['HTTP_PROXY'] || process.env['http_proxy']
12+
const httpsProxy = process.env['HTTPS_PROXY'] || process.env['https_proxy']
13+
14+
const proxy = httpProxy
15+
? new HttpsProxyAgent(httpProxy)
16+
: httpsProxy
17+
? new HttpsProxyAgent(httpProxy)
18+
: undefined
19+
1020
export const Octokit = Core.plugin(
1121
paginateRest,
1222
legacyRestEndpointMethods
@@ -15,7 +25,7 @@ export const Octokit = Core.plugin(
1525
...DEFAULTS,
1626
...options,
1727
request: {
18-
agent: new HttpsProxyAgent(),
28+
agent: proxy,
1929
...options.request
2030
}
2131
}

0 commit comments

Comments
 (0)