Skip to content
This repository was archived by the owner on Dec 19, 2025. It is now read-only.

Commit a2c9299

Browse files
committed
Add option for forcing a REST API call
1 parent 2346217 commit a2c9299

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

packages/api/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ export interface CheckOptions {
4040
* Currently only works when no token is specified.
4141
*/
4242
excludePrereleases?: boolean
43+
44+
/**
45+
* Will use the Github REST API (v3) even with a supplied token.
46+
*/
47+
forceRest?: boolean
4348
}
4449

4550
/**

packages/core/src/check.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ const check: CheckFunction = async function(options: CheckOptions): Promise<Chec
3131

3232
// decide what to do
3333
// when we have a token supplied, we will call the GraphQL API
34-
if (options.token) {
34+
if (options.forceRest) {
35+
return await rest(options)
36+
} else if (options.token) {
3537
return await graphql(options)
3638
} else {
3739
return await rest(options)

packages/core/test/test-graphql.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ test('graphql returns the same releases answer as rest', async (t) => {
1616
const responseGraphql = await versionCheck(opts) as CheckResult
1717
t.not(responseGraphql, undefined)
1818

19-
const responseRest = await versionCheck({ ...opts, token: false }) as CheckResult
19+
const responseRest = await versionCheck({ ...opts, forceRest: true }) as CheckResult
2020
t.not(responseRest, undefined)
2121

2222
t.is(responseGraphql.src, 'graphql')
@@ -28,7 +28,7 @@ test('graphql returns the same tags answer as rest', async (t) => {
2828
const responseGraphql = await versionCheck({ ...opts, fetchTags: true }) as CheckResult
2929
t.not(responseGraphql, undefined)
3030

31-
const responseRest = await versionCheck({ ...opts, token: false, fetchTags: true }) as CheckResult
31+
const responseRest = await versionCheck({ ...opts, forceRest: true, fetchTags: true }) as CheckResult
3232
t.not(responseRest, undefined)
3333

3434
t.is(responseGraphql.src, 'graphql')

0 commit comments

Comments
 (0)