Skip to content

Commit

Permalink
Make node-fetch available
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Michael O. Heggø authored and Dan Michael O. Heggø committed Jan 6, 2023
1 parent 311d596 commit f34078a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The following arguments will be provided:
- `glob` A reference to the [@actions/glob](https://github.com/actions/toolkit/tree/main/packages/glob) package
- `io` A reference to the [@actions/io](https://github.com/actions/toolkit/tree/main/packages/io) package
- `exec` A reference to the [@actions/exec](https://github.com/actions/toolkit/tree/main/packages/exec) package
- `fetch` A reference to the [node-fetch](https://github.com/node-fetch/node-fetch) package
- `require` A proxy wrapper around the normal Node.js `require` to enable
requiring relative paths (relative to the current working directory) and
requiring npm packages installed in the current working directory. If for
Expand Down
30 changes: 26 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@
"@octokit/core": "^3.5.1",
"@octokit/plugin-paginate-rest": "^2.17.0",
"@octokit/plugin-rest-endpoint-methods": "^6.3.0",
"@octokit/plugin-retry": "^3.0.9"
"@octokit/plugin-retry": "^3.0.9",
"node-fetch": "^2.6.7"
},
"devDependencies": {
"@types/jest": "^27.0.2",
"@types/node-fetch": "^2.6.2",
"@typescript-eslint/eslint-plugin": "^3.10.1",
"@typescript-eslint/parser": "^3.10.1",
"@vercel/ncc": "^0.36.0",
Expand Down
2 changes: 2 additions & 0 deletions src/async-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ 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

Expand All @@ -14,6 +15,7 @@ type AsyncFunctionArguments = {
exec: typeof exec
glob: typeof glob
io: typeof io
fetch: typeof fetch
require: NodeRequire
__original_require__: NodeRequire
}
Expand Down
4 changes: 3 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {RequestRequestOptions} from '@octokit/types'
import {callAsyncFunction} from './async-function'
import {getRetryOptions, parseNumberArray, RetryOptions} from './retry-options'
import {wrapRequire} from './wrap-require'
import fetch from 'node-fetch'

process.on('unhandledRejection', handleError)
main().catch(handleError)
Expand Down Expand Up @@ -56,7 +57,8 @@ async function main(): Promise<void> {
core,
exec,
glob,
io
io,
fetch
},
script
)
Expand Down

0 comments on commit f34078a

Please sign in to comment.