Add support for (optional) GITHUB_TOKEN env variable

This commit is contained in:
Vendicated
2023-04-10 22:05:21 +02:00
parent d1296d1708
commit 897df3a5d4
11 changed files with 93 additions and 24 deletions

View File

@@ -5,6 +5,7 @@
*/
import { existsSync, mkdirSync } from "fs";
import type { RequestOptions } from "https";
import { join } from "path";
import { USER_AGENT, VENCORD_FILES_DIR } from "../constants";
@@ -15,12 +16,16 @@ const API_BASE = "https://api.github.com/repos/Vendicated/Vencord";
const FILES_TO_DOWNLOAD = ["vencordDesktopMain.js", "preload.js", "vencordDesktopRenderer.js", "renderer.css"];
export async function githubGet(endpoint: string) {
return simpleGet(API_BASE + endpoint, {
const opts: RequestOptions = {
headers: {
Accept: "application/vnd.github+json",
"User-Agent": USER_AGENT
}
});
};
if (process.env.GITHUB_TOKEN) opts.headers!.Authorization = `Bearer ${process.env.GITHUB_TOKEN}`;
return simpleGet(API_BASE + endpoint, opts);
}
export async function downloadVencordFiles() {