Merge pull request #1459 from hackmdio/feat/improve-version-check

Improve version checker behavior
This commit is contained in:
Raccoon 2020-04-05 15:36:10 +08:00 committed by GitHub
commit e72bcfe0ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -30,11 +30,12 @@ async function checkVersion (ctx) {
const { statusCode, body: data } = await rp({
url: `${VERSION_CHECK_ENDPOINT}?v=${config.version}`,
method: 'GET',
json: true
json: true,
timeout: 3000
})
if (statusCode !== 200 || data.status === 'error') {
logger.error('Version check failed.')
logger.warn('Version check failed.')
return
}
@ -46,12 +47,12 @@ async function checkVersion (ctx) {
if (!data.latest) {
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) {
// ignore and skip version check
logger.error('Version check failed.')
logger.error(err)
logger.warn('Version check failed.')
logger.warn(err)
}
}