mirror of
https://github.com/ether/etherpad-lite.git
synced 2026-07-21 17:18:37 +00:00
* Move from deprecated request package to axios.
* Fixed package.json
* Another check.
* Fixing npm - hopefully the last.
* Remove double parsing of JSON.
* Bump bundled npm to also get rid of request in the bundled npm.
* Revert "Bump bundled npm to also get rid of request in the bundled npm."
This reverts commit b60fa4f435.
47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
'use strict';
|
|
const semver = require('semver');
|
|
const settings = require('./Settings');
|
|
const axios = require('axios');
|
|
let infos;
|
|
|
|
const loadEtherpadInformations = () =>
|
|
axios.get('https://static.etherpad.org/info.json')
|
|
.then(async resp => {
|
|
try {
|
|
infos = await resp.data;
|
|
if (infos === undefined || infos === null) {
|
|
await Promise.reject("Could not retrieve current version")
|
|
return
|
|
}
|
|
return await Promise.resolve(infos);
|
|
}
|
|
catch (err) {
|
|
return await Promise.reject(err);
|
|
}
|
|
})
|
|
|
|
|
|
exports.getLatestVersion = () => {
|
|
exports.needsUpdate();
|
|
return infos.latestVersion;
|
|
};
|
|
|
|
exports.needsUpdate = async (cb) => {
|
|
await loadEtherpadInformations()
|
|
.then((info) => {
|
|
if (semver.gt(info.latestVersion, settings.getEpVersion())) {
|
|
if (cb) return cb(true);
|
|
}
|
|
}).catch((err) => {
|
|
console.error(`Can not perform Etherpad update check: ${err}`);
|
|
if (cb) return cb(false);
|
|
});
|
|
};
|
|
|
|
exports.check = () => {
|
|
exports.needsUpdate((needsUpdate) => {
|
|
if (needsUpdate) {
|
|
console.warn(`Update available: Download the actual version ${infos.latestVersion}`);
|
|
}
|
|
});
|
|
};
|