MCPcopy Index your code
hub / github.com/actions/github-script / createConfiguredGetOctokit

Function createConfiguredGetOctokit

src/create-configured-getoctokit.ts:24–64  ·  view source on GitHub ↗
(
  rawGetOctokit: typeof getOctokit,
  defaultOptions: Record<string, unknown>,
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  ...defaultPlugins: any[]
)

Source from the content-addressed store, hash-verified

22 * - Default plugins (retry, requestLog) are always included; duplicates are skipped.
23 */
24export function createConfiguredGetOctokit(
25 rawGetOctokit: typeof getOctokit,
26 defaultOptions: Record<string, unknown>,
27 // eslint-disable-next-line @typescript-eslint/no-explicit-any
28 ...defaultPlugins: any[]
29): typeof getOctokit {
30 // eslint-disable-next-line @typescript-eslint/no-explicit-any
31 return ((token: string, options?: any, ...plugins: any[]) => {
32 const cleanDefaults = stripUndefined(defaultOptions)
33 const userOpts = stripUndefined(options ?? {})
34
35 const defaultRequest =
36 (cleanDefaults.request as Record<string, unknown> | undefined) ?? {}
37 const userRequest = stripUndefined(
38 (userOpts.request as Record<string, unknown> | undefined) ?? {}
39 )
40
41 const defaultRetry =
42 (cleanDefaults.retry as Record<string, unknown> | undefined) ?? {}
43 const userRetry = stripUndefined(
44 (userOpts.retry as Record<string, unknown> | undefined) ?? {}
45 )
46
47 const merged = {
48 ...cleanDefaults,
49 ...userOpts,
50 request: {...defaultRequest, ...userRequest},
51 retry: {...defaultRetry, ...userRetry}
52 }
53
54 // Deduplicate: default plugins first, then user plugins that aren't already present
55 const allPlugins = [...defaultPlugins]
56 for (const plugin of plugins) {
57 if (!allPlugins.includes(plugin)) {
58 allPlugins.push(plugin)
59 }
60 }
61
62 return rawGetOctokit(token, merged, ...allPlugins)
63 }) as typeof getOctokit
64}

Callers 2

mainFunction · 0.90

Calls 1

stripUndefinedFunction · 0.85

Tested by

no test coverage detected