mirror of https://github.com/status-im/codimd.git
Merge pull request #1459 from hackmdio/feat/improve-version-check
Improve version checker behavior
This commit is contained in:
commit
e72bcfe0ea
|
@ -30,11 +30,12 @@ async function checkVersion (ctx) {
|
||||||
const { statusCode, body: data } = await rp({
|
const { statusCode, body: data } = await rp({
|
||||||
url: `${VERSION_CHECK_ENDPOINT}?v=${config.version}`,
|
url: `${VERSION_CHECK_ENDPOINT}?v=${config.version}`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
json: true
|
json: true,
|
||||||
|
timeout: 3000
|
||||||
})
|
})
|
||||||
|
|
||||||
if (statusCode !== 200 || data.status === 'error') {
|
if (statusCode !== 200 || data.status === 'error') {
|
||||||
logger.error('Version check failed.')
|
logger.warn('Version check failed.')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,12 +47,12 @@ async function checkVersion (ctx) {
|
||||||
if (!data.latest) {
|
if (!data.latest) {
|
||||||
const { version, link } = data.versionItem
|
const { version, link } = data.versionItem
|
||||||
|
|
||||||
logger.warn(`Your CodiMD version is out of date! The latest version is ${version}. Please see what's new on ${link}.`)
|
logger.info(`Your CodiMD version is out of date! The latest version is ${version}. Please see what's new on ${link}.`)
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// ignore and skip version check
|
// ignore and skip version check
|
||||||
logger.error('Version check failed.')
|
logger.warn('Version check failed.')
|
||||||
logger.error(err)
|
logger.warn(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue