mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 14:13:34 +01:00
lint: src/node/utils/UpdateCheck.js
This commit is contained in:
parent
f8323eae89
commit
02c1bf7d81
1 changed files with 14 additions and 15 deletions
|
@ -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}`);
|
||||
|
|
Loading…
Reference in a new issue