mirror of
https://github.com/actions/github-script.git
synced 2025-12-25 23:23:07 +00:00
Move wrapRequire to its own module
This commit is contained in:
16
src/wrap-require.ts
Normal file
16
src/wrap-require.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import * as path from 'path'
|
||||
|
||||
declare const __non_webpack_require__: NodeRequire
|
||||
|
||||
export 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)
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user