mirror of
https://github.com/ApfelTeeSaft/Reload-Backend.git
synced 2026-08-27 03:43:27 +00:00
19 lines
808 B
JavaScript
19 lines
808 B
JavaScript
const log = require("../structs/log.js");
|
|
const fetch = require("node-fetch");
|
|
|
|
class CheckForUpdate {
|
|
static async checkForUpdate(currentVersion) {
|
|
const packageJson = await fetch('https://raw.githubusercontent.com/Project-Reload/Reload-Backend/refs/heads/main/package.json')
|
|
.then(res => res.json());
|
|
|
|
const latestVersion = packageJson.version.replace(/\./g, "");
|
|
const currentVersionFormatted = currentVersion.replace(/\./g, "");
|
|
|
|
if (parseFloat(latestVersion) > parseFloat(currentVersionFormatted)) {
|
|
const message = `A new version of the Backend has been released! ${currentVersion} -> ${packageJson.version}`;
|
|
log.checkforupdate(`${message}\nDownload it from the GitHub repo.`);
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = CheckForUpdate; |