2020-07-16 10:57:13 +02:00
|
|
|
import {Octokit as Core} from '@octokit/core'
|
|
|
|
import {paginateRest} from '@octokit/plugin-paginate-rest'
|
|
|
|
import {restEndpointMethods} from '@octokit/plugin-rest-endpoint-methods'
|
2023-04-05 01:41:18 +02:00
|
|
|
import {HttpsProxyAgent} from 'https-proxy-agent'
|
|
|
|
import {getProxyForUrl} from 'proxy-from-env'
|
2020-07-16 10:57:13 +02:00
|
|
|
export {RestEndpointMethodTypes} from '@octokit/plugin-rest-endpoint-methods'
|
|
|
|
export {OctokitOptions} from '@octokit/core/dist-types/types'
|
|
|
|
|
2021-05-22 02:32:10 +02:00
|
|
|
export const Octokit = Core.plugin(
|
|
|
|
paginateRest,
|
|
|
|
restEndpointMethods,
|
|
|
|
autoProxyAgent
|
|
|
|
)
|
|
|
|
|
2022-10-18 05:14:51 +02:00
|
|
|
// Octokit plugin to support the standard environment variables http_proxy, https_proxy and no_proxy
|
2021-05-22 02:32:10 +02:00
|
|
|
function autoProxyAgent(octokit: Core) {
|
|
|
|
octokit.hook.before('request', options => {
|
2023-04-05 01:41:18 +02:00
|
|
|
const proxy = getProxyForUrl(options.baseUrl)
|
|
|
|
if (proxy) {
|
|
|
|
options.request.agent = new HttpsProxyAgent(proxy)
|
|
|
|
}
|
2021-05-22 02:32:10 +02:00
|
|
|
})
|
|
|
|
}
|