UNPKG

cybertron-utils

Version:
27 lines (25 loc) 764 B
const chalk = require('chalk'); const boxen = require('boxen'); const checkForUpdate = require('update-check'); const pkg = require('../package.json'); module.exports = async () => { let update = null; try { update = await checkForUpdate(pkg); } catch (err) { console.error(chalk.red(`Failed to check for updates: ${err}`)); } if (update) { let installCommand = `npm i -g cybertron-utils` let message = 'Update available ' + chalk.dim(pkg.version) + chalk.reset(' → ') + chalk.green(update.latest) + ' \nRun ' + chalk.cyan(installCommand) + ' to update' let boxenOpts = { padding: 1, margin: 1, align: 'center', borderColor: 'yellow', borderStyle: 'double' } const result = boxen(message, boxenOpts) console.log(result) } }