File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 11import getUserAgent from "universal-user-agent" ;
2+ import { Collection , HookCollection } from "before-after-hook" ;
23import { request } from "@octokit/request" ;
34
45import { OctokitOptions , Parameters , Plugin } from "./types" ;
@@ -18,10 +19,13 @@ export class Octokit {
1819 }
1920
2021 constructor ( options : OctokitOptions = { } ) {
22+ const hook = new Collection ( ) ;
2123 const requestDefaults : Required < Parameters > = {
2224 baseUrl : request . endpoint . DEFAULTS . baseUrl ,
2325 headers : { } ,
24- request : options . request || { } ,
26+ request : Object . assign ( { } , options . request , {
27+ hook : hook . bind ( null , "request" )
28+ } ) ,
2529 mediaType : {
2630 previews : [ ] ,
2731 format : ""
@@ -45,6 +49,7 @@ export class Octokit {
4549 }
4650
4751 this . request = request . defaults ( requestDefaults ) ;
52+ this . hook = hook ;
4853
4954 // apply plugins
5055 // https://stackoverflow.com/a/16345172
@@ -54,6 +59,7 @@ export class Octokit {
5459
5560 // assigned during constructor
5661 request : typeof request ;
62+ hook : HookCollection ;
5763
5864 // allow for plugins to extend the Octokit instance
5965 [ key : string ] : any ;
You can’t perform that action at this time.
0 commit comments