mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2024-11-24 19:30:58 -05:00
21 lines
484 B
JavaScript
21 lines
484 B
JavaScript
module.exports = authenticationPlugin
|
|
|
|
const beforeRequest = require('./before-request')
|
|
const requestError = require('./request-error')
|
|
const validate = require('./validate')
|
|
|
|
function authenticationPlugin (octokit, options) {
|
|
if (!options.auth) {
|
|
return
|
|
}
|
|
|
|
validate(options.auth)
|
|
|
|
const state = {
|
|
octokit,
|
|
auth: options.auth
|
|
}
|
|
|
|
octokit.hook.before('request', beforeRequest.bind(null, state))
|
|
octokit.hook.error('request', requestError.bind(null, state))
|
|
}
|