lint: src/node/utils/UpdateCheck.js

This commit is contained in:
John McLear 2021-01-21 21:06:52 +00:00 committed by Richard Hansen
parent f8323eae89
commit 02c1bf7d81

View file

@ -1,30 +1,29 @@
'use strict';
const semver = require('semver');
const settings = require('./Settings');
const request = require('request');
let infos;
function loadEtherpadInformations() {
return new Promise((resolve, reject) => {
request('https://static.etherpad.org/info.json', (er, response, body) => {
if (er) return reject(er);
const loadEtherpadInformations = () => new Promise((resolve, reject) => {
request('https://static.etherpad.org/info.json', (er, response, body) => {
if (er) return reject(er);
try {
infos = JSON.parse(body);
return resolve(infos);
} catch (err) {
return reject(err);
}
});
try {
infos = JSON.parse(body);
return resolve(infos);
} catch (err) {
return reject(err);
}
});
}
});
exports.getLatestVersion = function () {
exports.getLatestVersion = () => {
exports.needsUpdate();
return infos.latestVersion;
};
exports.needsUpdate = function (cb) {
exports.needsUpdate = (cb) => {
loadEtherpadInformations().then((info) => {
if (semver.gt(info.latestVersion, settings.getEpVersion())) {
if (cb) return cb(true);
@ -35,7 +34,7 @@ exports.needsUpdate = function (cb) {
});
};
exports.check = function () {
exports.check = () => {
exports.needsUpdate((needsUpdate) => {
if (needsUpdate) {
console.warn(`Update available: Download the actual version ${infos.latestVersion}`);