mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 00:47:01 +00:00
feature(cloudcmd) add checkUpdate
This commit is contained in:
parent
9257cb4490
commit
1f220c8761
2 changed files with 27 additions and 1 deletions
|
|
@ -4,7 +4,6 @@
|
|||
'use strict';
|
||||
|
||||
var Info = require('../package'),
|
||||
|
||||
DIR = __dirname + '/../',
|
||||
DIR_LIB = DIR + 'lib/',
|
||||
DIR_SERVER = DIR_LIB + 'server/',
|
||||
|
|
@ -68,6 +67,8 @@
|
|||
if (args.repl)
|
||||
repl();
|
||||
|
||||
checkUpdate();
|
||||
|
||||
port(args.port);
|
||||
password(args.password);
|
||||
|
||||
|
|
@ -181,4 +182,27 @@
|
|||
require(DIR_LIB + '/server/repl');
|
||||
}
|
||||
|
||||
function checkUpdate() {
|
||||
var load = require('package-json'),
|
||||
chalk = require('chalk'),
|
||||
rendy = require('rendy');
|
||||
|
||||
load.field('cloudcmd', 'version', function(error, version) {
|
||||
var latest, current,
|
||||
is = version !== Info.version;
|
||||
|
||||
if (!error && is) {
|
||||
latest = rendy('update available: {{ latest }}', {
|
||||
latest: chalk.green.bold('v' + version),
|
||||
});
|
||||
|
||||
current = chalk.dim(rendy('(current: v{{ current }})', {
|
||||
current: Info.version
|
||||
}));
|
||||
|
||||
console.log('%s %s', latest, current);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
},
|
||||
"subdomain": "cloudcmd",
|
||||
"dependencies": {
|
||||
"chalk": "~1.0.0",
|
||||
"checkup": "~1.3.0",
|
||||
"console-io": "~2.2.0",
|
||||
"copymitter": "~1.8.0",
|
||||
|
|
@ -53,6 +54,7 @@
|
|||
"minify": "~1.4.0",
|
||||
"minimist": "~1.1.0",
|
||||
"mollify": "~1.0.0",
|
||||
"package-json": "~1.2.0",
|
||||
"pipe-io": "~1.1.1",
|
||||
"ponse": "~1.4.0",
|
||||
"rendy": "~1.1.0",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue