mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
fix(cloudcmd) showUpdateInfo: unhandled promise rejection
This commit is contained in:
parent
263e9b7337
commit
1994b84810
1 changed files with 23 additions and 17 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue