Skip to content

Commit cd63963

Browse files
author
Illia Obukhau
committed
fix(run-e2e): throw error when GITHUB_TOKEN is missing
1 parent d965d78 commit cd63963

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

automation/run-e2e/lib/utils.mjs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,26 @@ export async function fetchWithReport(url, init) {
5757
}
5858

5959
export async function fetchGithubRestAPI(url, init = {}) {
60+
const token = process.env.GITHUB_TOKEN;
61+
assert.ok(typeof token === "string" && token.length > 0, "GITHUB_TOKEN is missing");
62+
6063
return fetchWithReport(url, {
6164
...init,
6265
headers: {
6366
Accept: "application/vnd.github+json",
64-
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
67+
Authorization: `Bearer ${token}`,
6568
"X-GitHub-Api-Version": "2022-11-28",
6669
...init.headers
6770
}
6871
});
6972
}
7073

71-
export async function await200(url = "http://localhost:8080", attempts = 50) {
74+
export async function await200(url = "http://127.0.0.1:8080", attempts = 50) {
7275
let n = 0;
7376
while (++n <= attempts) {
7477
console.log(c.cyan(`GET ${url} ${n}`));
75-
let response;
76-
try {
77-
response = await fetch(url);
78-
} catch {
79-
// ignore
80-
}
81-
82-
const { ok, status } = response ?? {};
78+
const response = await fetch(url);
79+
const { ok, status } = response;
8380

8481
if (ok && status === 200) {
8582
console.log(c.green(`200 OK, continue`));

0 commit comments

Comments
 (0)