3
0
Fork 0
mirror of https://gitea.com/actions/setup-node.git synced 2024-11-28 13:09:32 +01:00
setup-node/node_modules/@octokit/rest/plugins/authentication-deprecated/index.js
Danny McCormick 5273d0df9c Add auth
2019-08-06 18:29:44 -04:00

26 lines
892 B
JavaScript

module.exports = authenticationPlugin
const { Deprecation } = require('deprecation')
const once = require('once')
const deprecateAuthenticate = once((log, deprecation) => log.warn(deprecation))
const authenticate = require('./authenticate')
const beforeRequest = require('./before-request')
const requestError = require('./request-error')
function authenticationPlugin (octokit, options) {
if (options.auth) {
octokit.authenticate = () => {
deprecateAuthenticate(octokit.log, new Deprecation('[@octokit/rest] octokit.authenticate() is deprecated and has no effect when "auth" option is set on Octokit constructor'))
}
return
}
const state = {
octokit,
auth: false
}
octokit.authenticate = authenticate.bind(null, state)
octokit.hook.before('request', beforeRequest.bind(null, state))
octokit.hook.error('request', requestError.bind(null, state))
}