mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2024-12-28 13:35:49 +00:00
23 lines
688 B
JavaScript
23 lines
688 B
JavaScript
|
module.exports = octokitDebug
|
||
|
|
||
|
function octokitDebug (octokit) {
|
||
|
octokit.hook.wrap('request', (request, options) => {
|
||
|
octokit.log.debug(`request`, options)
|
||
|
const start = Date.now()
|
||
|
const requestOptions = octokit.request.endpoint.parse(options)
|
||
|
const path = requestOptions.url.replace(options.baseUrl, '')
|
||
|
|
||
|
return request(options)
|
||
|
|
||
|
.then(response => {
|
||
|
octokit.log.info(`${requestOptions.method} ${path} - ${response.status} in ${Date.now() - start}ms`)
|
||
|
return response
|
||
|
})
|
||
|
|
||
|
.catch(error => {
|
||
|
octokit.log.info(`${requestOptions.method} ${path} - ${error.status} in ${Date.now() - start}ms`)
|
||
|
throw error
|
||
|
})
|
||
|
})
|
||
|
}
|