Spaces:
Paused
Paused
| import {AsyncLocalStorage} from 'async_hooks' | |
| export interface PRIXContext { | |
| probotContext: any | |
| octokit: any | |
| repo: { | |
| owner: string | |
| repo: string | |
| } | |
| workingDir?: string | |
| } | |
| // Global context storage for current execution thread | |
| export const als = new AsyncLocalStorage<PRIXContext>() | |
| /** | |
| * Access the current execution context safely from anywhere in the codebase. | |
| */ | |
| export const getCurrentContext = (): PRIXContext | undefined => { | |
| return als.getStore() | |
| } | |
| /** | |
| * Helper to get octokit from current context | |
| */ | |
| export const getSafeOctokit = (): any => { | |
| return als.getStore()?.octokit | |
| } | |
| /** | |
| * Helper to get repo info from current context | |
| */ | |
| export const getSafeRepo = () => { | |
| return als.getStore()?.repo | |
| } | |