mirror of
https://github.com/actions/github-script.git
synced 2025-12-09 00:26:20 +00:00
Move wrapRequire to its own module
This commit is contained in:
17
src/main.ts
17
src/main.ts
@@ -2,10 +2,8 @@ import * as core from '@actions/core'
|
||||
import {context, getOctokit} from '@actions/github'
|
||||
import * as glob from '@actions/glob'
|
||||
import * as io from '@actions/io'
|
||||
import * as path from 'path'
|
||||
import {callAsyncFunction} from './async-function'
|
||||
|
||||
declare const __non_webpack_require__: NodeRequire
|
||||
import {wrapRequire} from './wrap-require'
|
||||
|
||||
process.on('unhandledRejection', handleError)
|
||||
main().catch(handleError)
|
||||
@@ -62,19 +60,6 @@ async function main(): Promise<void> {
|
||||
core.setOutput('result', output)
|
||||
}
|
||||
|
||||
const wrapRequire = new Proxy(__non_webpack_require__, {
|
||||
apply: (target, thisArg, [moduleID]) => {
|
||||
if (moduleID.startsWith('.')) {
|
||||
moduleID = path.join(process.cwd(), moduleID)
|
||||
}
|
||||
return target.apply(thisArg, [moduleID])
|
||||
},
|
||||
|
||||
get: (target, prop, receiver) => {
|
||||
Reflect.get(target, prop, receiver)
|
||||
}
|
||||
})
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function handleError(err: any): void {
|
||||
console.error(err)
|
||||
|
||||
Reference in New Issue
Block a user