Skip to content

Commit

Permalink
feat: add bun as a supported runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Nov 8, 2022
1 parent 1e97c67 commit 707efd1
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 5 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,23 @@ jobs:
- name: Run Test Suite
run: npm run tap:workers

bun:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@v3
- run: curl https://bun.sh/install | bash
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: lts/hydrogen # 18
cache: 'npm'
check-latest: true
- run: npm clean-install
- name: Run Test Suite
run: npm run tap:bun

browsers:
runs-on: ubuntu-latest
strategy:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,4 @@ tap/run-*.cjs

*.zip
*.txt
*.bun
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ The supported JavaScript runtimes include ones that support the utilized Web API

These are _(this is not an exhaustive list)_:
- Browsers
- Bun
- Cloudflare Workers
- Deno
- Electron
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"authorization",
"basic",
"browser",
"bun",
"certified",
"client",
"cloudflare",
Expand Down Expand Up @@ -53,6 +54,7 @@
"format-check": "npm run _format -- --check",
"prepack": "npm run format && npm run docs && ./examples/.update-diffs.sh && git diff --quiet && npm run test && npm run build",
"tap:browsers": "./tap/.browsers.sh",
"tap:bun": "./tap/.bun.sh",
"tap:deno": "./tap/.deno.sh",
"tap:edge-runtime": "./tap/.edge-runtime.sh",
"tap:electron": "./tap/.electron.sh",
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,7 @@ async function authenticatedRequest(
options?: Omit<HttpRequestOptions, 'headers'> & AuthenticatedRequestOptions,
) {
await clientAuthentication(as, client, body, headers, options?.clientPrivateKey)
headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8')

return fetch(url.href, {
body,
Expand Down
1 change: 1 addition & 0 deletions tap/.bun.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
~/.bun/bin/bun run tap/run-bun.ts
2 changes: 1 addition & 1 deletion tap/code_flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default (QUnit: QUnit) => {
const authorizationUrl = new URL(as.authorization_endpoint!)
authorizationUrl.searchParams.set('client_id', client.client_id)
authorizationUrl.searchParams.set('request_uri', request_uri)
await fetch(authorizationUrl, { redirect: 'manual' }).catch(() => {})
await fetch(authorizationUrl.href, { redirect: 'manual' }).catch(() => {})
currentUrl = new URL((await exposed()).authorization_endpoint_response_redirect)
}

Expand Down
11 changes: 11 additions & 0 deletions tap/run-bun.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import QUnit from 'qunit'
import run from './run.js'

const stats: QUnit.DoneDetails = await new Promise((resolve) => {
run(QUnit, resolve)
})

if (stats?.failed !== 0) {
// @ts-ignore
process.exit(1)
}
6 changes: 2 additions & 4 deletions tap/run.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type QUnit from 'qunit'

export default async (QUnit: QUnit, done?: (details: QUnit.DoneDetails) => void) => {
export default async (QUnit: QUnit, done: (details: QUnit.DoneDetails) => void) => {
// @ts-ignore
QUnit.reporters.tap.init(QUnit)
QUnit.config.autostart = false
Expand All @@ -18,7 +18,5 @@ export default async (QUnit: QUnit, done?: (details: QUnit.DoneDetails) => void)
await module(QUnit)
}
QUnit.start()
if (done) {
QUnit.done(done)
}
QUnit.done(done)
}

0 comments on commit 707efd1

Please sign in to comment.