mirror of
https://forgejo.stefka.eu/jiriks74/create-pull-request.git
synced 2025-01-18 16:01:06 +01:00
feat: revise proxy implementation
This commit is contained in:
parent
e9de0054f9
commit
39e13ab4bf
8 changed files with 92 additions and 53475 deletions
|
@ -1,7 +1,8 @@
|
|||
import {Octokit as Core} from '@octokit/core'
|
||||
import {paginateRest} from '@octokit/plugin-paginate-rest'
|
||||
import {restEndpointMethods} from '@octokit/plugin-rest-endpoint-methods'
|
||||
import ProxyAgent from 'proxy-agent'
|
||||
import {HttpsProxyAgent} from 'https-proxy-agent'
|
||||
import {getProxyForUrl} from 'proxy-from-env'
|
||||
export {RestEndpointMethodTypes} from '@octokit/plugin-rest-endpoint-methods'
|
||||
export {OctokitOptions} from '@octokit/core/dist-types/types'
|
||||
|
||||
|
@ -13,16 +14,10 @@ export const Octokit = Core.plugin(
|
|||
|
||||
// Octokit plugin to support the standard environment variables http_proxy, https_proxy and no_proxy
|
||||
function autoProxyAgent(octokit: Core) {
|
||||
const proxy =
|
||||
process.env.https_proxy ||
|
||||
process.env.HTTPS_PROXY ||
|
||||
process.env.http_proxy ||
|
||||
process.env.HTTP_PROXY
|
||||
|
||||
if (!proxy) return
|
||||
|
||||
const agent = new ProxyAgent()
|
||||
octokit.hook.before('request', options => {
|
||||
options.request.agent = agent
|
||||
const proxy = getProxyForUrl(options.url)
|
||||
if (proxy) {
|
||||
options.request.agent = new HttpsProxyAgent(proxy)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue