mirror of
https://github.com/actions/github-script.git
synced 2025-12-08 08:06:23 +00:00
23 lines
602 B
TypeScript
23 lines
602 B
TypeScript
import * as core from '@actions/core'
|
|
import {Context} from '@actions/github/lib/context'
|
|
import {GitHub} from '@actions/github/lib/utils'
|
|
import * as io from '@actions/io'
|
|
|
|
const AsyncFunction = Object.getPrototypeOf(async () => null).constructor
|
|
|
|
type AsyncFunctionArguments = {
|
|
context: Context
|
|
core: typeof core
|
|
github: InstanceType<typeof GitHub>
|
|
io: typeof io
|
|
require: NodeRequire
|
|
}
|
|
|
|
export function callAsyncFunction<T>(
|
|
args: AsyncFunctionArguments,
|
|
source: string
|
|
): Promise<T> {
|
|
const fn = new AsyncFunction(...Object.keys(args), source)
|
|
return fn(...Object.values(args))
|
|
}
|