Skip to content

Commit

Permalink
fix: update messaging when checking version
Browse files Browse the repository at this point in the history
  • Loading branch information
10ko committed Jun 27, 2019
1 parent 77f80bf commit afebab2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 4 additions & 5 deletions garden-service/src/cli/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import qs = require("qs")
import { platform, release } from "os"
import { LogEntry } from "../logger/log-entry"
import { VERSION_CHECK_URL } from "../constants"
import { printHeader } from "../logger/util"
import { printWarningMessage } from "../logger/util"
import { GlobalConfigStore, globalConfigKeys } from "../config-store"
import moment = require("moment")

Expand Down Expand Up @@ -228,13 +228,12 @@ export async function checkForUpdates(config: GlobalConfigStore, logger: LogEntr
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.data.status === "OUTDATED") {
printHeader(logger, res.data.message, "warning")
} else {
printHeader(logger, res.data.message, "thumbsup")
printWarningMessage(logger, res.data.message)
await config.set([globalConfigKeys.lastVersionCheck], { lastRun: new Date() })
}
await config.set([globalConfigKeys.lastVersionCheck], { lastRun: new Date() })
}
} catch (err) {
logger.verbose("Something went wrong while checking for the latest Garden version.")
Expand Down
8 changes: 8 additions & 0 deletions garden-service/src/logger/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,11 @@ export function printHeader(log: LogEntry, command: string, emoji?: EmojiName):
export function printFooter(log: LogEntry) {
return printWithEmoji(log, "Done!", "heavy_check_mark")
}

export function printWarningMessage(log: LogEntry, text: string) {
const msg = combine([
[log.root.useEmoji ? printEmoji("warning") : ""],
[chalk.bold.yellow(text)],
])
return log.info(msg)
}

0 comments on commit afebab2

Please sign in to comment.