fix(cloudcmd) showUpdateInfo: unhandled promise rejection

This commit is contained in:
coderaiser 2017-01-25 10:58:08 +02:00
parent 263e9b7337
commit 1994b84810

View file

@ -196,23 +196,29 @@ function repl() {
function checkUpdate() {
const load = require('package-json');
const chalk = require('chalk');
const rendy = require('rendy');
const noop = () => {};
load(Info.name, 'latest').then((data) => {
const version = data.version;
if (version !== Info.version) {
const latest = rendy('update available: {{ latest }}', {
latest: chalk.green.bold('v' + version),
});
const current = chalk.dim(rendy('(current: v{{ current }})', {
current: Info.version
}));
console.log('%s %s', latest, current);
}
});
load(Info.name, 'latest')
.then(showUpdateInfo)
.catch(noop);
}
function showUpdateInfo(data) {
const version = data.version;
if (version !== Info.version) {
const chalk = require('chalk');
const rendy = require('rendy');
const latest = rendy('update available: {{ latest }}', {
latest: chalk.green.bold('v' + version),
});
const current = chalk.dim(rendy('(current: v{{ current }})', {
current: Info.version
}));
console.log('%s %s', latest, current);
}
}