Skip to content

Commit

Permalink
fix(cli): missing version update message
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald authored and eysi09 committed May 15, 2021
1 parent 143e537 commit a8fa1a3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/src/cli/helpers.ts
Expand Up @@ -23,7 +23,7 @@ import { LogEntry } from "../logger/log-entry"
import { STATIC_DIR, VERSION_CHECK_URL, gardenEnv } from "../constants"
import { printWarningMessage } from "../logger/util"
import { GlobalConfigStore, globalConfigKeys } from "../config-store"
import { got, GotResponse } from "../util/http"
import { got } from "../util/http"
import { getUserId } from "../analytics/analytics"
import minimist = require("minimist")
import { renderTable, tablePresets, naturalList } from "../util/string"
Expand Down Expand Up @@ -77,15 +77,15 @@ export async function checkForUpdates(config: GlobalConfigStore, logger: LogEntr
headers["X-ci-name"] = ci.name
}

const res = await got(`${VERSION_CHECK_URL}?${qs.stringify(query)}`, { headers }).json<GotResponse<any>>()
const res = await got(`${VERSION_CHECK_URL}?${qs.stringify(query)}`, { headers }).json<any>()
const configObj = await config.get()
const showMessage =
configObj.lastVersionCheck && moment().subtract(1, "days").isAfter(moment(configObj.lastVersionCheck.lastRun))

// we check again for lastVersionCheck because in the first run it doesn't exist
if (showMessage || !configObj.lastVersionCheck) {
if (res.body.status === "OUTDATED") {
printWarningMessage(logger, res.body.message)
if (res.status === "OUTDATED") {
res.message && printWarningMessage(logger, res.message)
await config.set([globalConfigKeys.lastVersionCheck], { lastRun: new Date() })
}
}
Expand Down

0 comments on commit a8fa1a3

Please sign in to comment.