mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
25 lines
906 B
JavaScript
25 lines
906 B
JavaScript
import { VERSION } from "./version";
|
|
/**
|
|
* @param octokit Octokit instance
|
|
* @param options Options passed to Octokit constructor
|
|
*/
|
|
export function requestLog(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;
|
|
});
|
|
});
|
|
}
|
|
requestLog.VERSION = VERSION;
|