Updater: Ignore non release commits

This commit is contained in:
Vendicated 2022-11-17 00:44:52 +01:00
parent 47d127a895
commit 8b0911b86a
No known key found for this signature in database
GPG Key ID: EC781ADFB93EFFA3
2 changed files with 11 additions and 7 deletions

@ -29,7 +29,7 @@ import { get } from "../simpleGet";
import { calculateHashes, serializeErrors } from "./common";
const API_BASE = `https://api.github.com/repos/${gitRemote}`;
let PendingUpdates = [] as [string, Buffer][];
let PendingUpdates = [] as [string, string][];
async function githubGet(endpoint: string) {
return get(API_BASE + endpoint, {
@ -46,6 +46,9 @@ async function githubGet(endpoint: string) {
}
async function calculateGitChanges() {
const isOutdated = await fetchUpdates();
if (!isOutdated) return [];
const res = await githubGet(`/compare/${gitHash}...HEAD`);
const data = JSON.parse(res.toString("utf-8"));
@ -63,18 +66,20 @@ async function fetchUpdates() {
const data = JSON.parse(release.toString());
const hash = data.name.slice(data.name.lastIndexOf(" ") + 1);
if (hash === gitHash)
return true;
return false;
await Promise.all(data.assets.map(async ({ name, browser_download_url }) => {
data.assets.forEach(({ name, browser_download_url }) => {
if (["patcher.js", "preload.js", "renderer.js"].some(s => name.startsWith(s))) {
PendingUpdates.push([name, await get(browser_download_url)]);
PendingUpdates.push([name, browser_download_url]);
}
}));
});
return true;
}
async function applyUpdates() {
await Promise.all(PendingUpdates.map(([name, data]) => writeFile(join(__dirname, name), data)));
await Promise.all(PendingUpdates.map(
async ([name, data]) => writeFile(join(__dirname, name), await get(data)))
);
PendingUpdates = [];
return true;
}

@ -152,6 +152,5 @@ if (readFileSync(injectorPath, "utf-8").includes('require("../app.asar")')) {
return loadModule.apply(this, arguments);
};
} else {
console.log(require.main!.filename);
require(require.main!.filename);
}