mirror of
https://github.com/actions/github-script.git
synced 2025-12-20 05:52:28 +00:00
30 lines
807 B
TypeScript
30 lines
807 B
TypeScript
import * as core from '@actions/core'
|
|
import * as exec from '@actions/exec'
|
|
import {Context} from '@actions/github/lib/context'
|
|
import {GitHub} from '@actions/github/lib/utils'
|
|
import * as glob from '@actions/glob'
|
|
import * as io from '@actions/io'
|
|
import fetch from 'node-fetch'
|
|
|
|
const AsyncFunction = Object.getPrototypeOf(async () => null).constructor
|
|
|
|
type AsyncFunctionArguments = {
|
|
context: Context
|
|
core: typeof core
|
|
github: InstanceType<typeof GitHub>
|
|
exec: typeof exec
|
|
glob: typeof glob
|
|
io: typeof io
|
|
fetch: typeof fetch
|
|
require: NodeRequire
|
|
__original_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))
|
|
}
|