* Check if the current cli is out of date * @param log - Log function
(log = console.log)
| 276 | * @param log - Log function |
| 277 | */ |
| 278 | async function checkCliVersion(log = console.log) { |
| 279 | const latestCliVersion = await latestVersion('@loopback/cli'); |
| 280 | if (latestCliVersion !== cliPkg.version) { |
| 281 | const current = chalk.grey(cliPkg.version); |
| 282 | const latest = chalk.green(latestCliVersion); |
| 283 | const cmd = chalk.cyan(`npm i -g ${cliPkg.name}`); |
| 284 | const message = ` |
| 285 | Update available ${current} ${chalk.reset(' → ')} ${latest} |
| 286 | Run ${cmd} to update.`; |
| 287 | log(message); |
| 288 | } else { |
| 289 | log(chalk.green(`${cliPkg.name}@${cliPkg.version} is up to date.`)); |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | exports.printVersions = printVersions; |
| 294 | exports.checkCliVersion = checkCliVersion; |
no test coverage detected