Various updates.
This commit is contained in:
parent
29398b9869
commit
84e6228f90
@ -4,4 +4,4 @@
|
||||
|
||||
//====================================================================
|
||||
|
||||
require('../')(process.argv.slice(2));
|
||||
require('exec-promise')(require('..'));
|
||||
|
@ -23,20 +23,21 @@
|
||||
"url": "https://github.com/vatesfr/xo-cli"
|
||||
},
|
||||
"dependencies": {
|
||||
"bluebird": "^1.1.0",
|
||||
"bluebird": "^1.2.4",
|
||||
"chalk": "^0.4.0",
|
||||
"inquirer": "^0.4.1",
|
||||
"l33teral": "^2.0.3",
|
||||
"exec-promise": "^0.2.4",
|
||||
"inquirer": "^0.5.0",
|
||||
"l33teral": "^2.0.4",
|
||||
"lodash": "^2.4.1",
|
||||
"mkdirp": "^0.3.5",
|
||||
"mkdirp": "^0.5.0",
|
||||
"nomnom": "^1.6.2",
|
||||
"ws": "^0.4.31",
|
||||
"xdg": "^0.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^1.9.0",
|
||||
"human-format": "^0.1.0",
|
||||
"mocha": "^1.18.0",
|
||||
"chai": "^1.9.1",
|
||||
"human-format": "^0.1.3",
|
||||
"mocha": "^1.19.0",
|
||||
"mocha-promise": "0.0.1"
|
||||
},
|
||||
"scripts": {
|
||||
|
@ -3,7 +3,7 @@
|
||||
//====================================================================
|
||||
|
||||
var _ = require('lodash');
|
||||
var nomnom = require('nomnom');
|
||||
var nomnom = require('nomnom')();
|
||||
var Promise = require('bluebird');
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
@ -14,6 +14,15 @@ var Xo = require('./xo');
|
||||
|
||||
//====================================================================
|
||||
|
||||
//`nomnom.print()` version which does not use `process.exit()`.
|
||||
nomnom.print = function (str, code) {
|
||||
throw ''+ str;
|
||||
|
||||
// TODO: handles code.
|
||||
};
|
||||
|
||||
//====================================================================
|
||||
|
||||
var connect = function () {
|
||||
return config.load().bind({}).then(function (config) {
|
||||
if (!config.server)
|
||||
@ -180,7 +189,9 @@ module.exports = function (argv) {
|
||||
},
|
||||
}, function (opts) {
|
||||
return connect().then(function (xo) {
|
||||
return xo.send('system.methodSignature', {name: opts.name}).then(console.log);
|
||||
return xo.send('system.methodSignature', {
|
||||
name: opts.name
|
||||
}).then(console.log);
|
||||
});
|
||||
});
|
||||
|
||||
@ -203,40 +214,19 @@ module.exports = function (argv) {
|
||||
});
|
||||
|
||||
// TODO: handle global `--config FILE` option.
|
||||
nomnom
|
||||
var opts = nomnom
|
||||
.option('version', {
|
||||
flag: true,
|
||||
help: 'prints the current version of xo-cli',
|
||||
callback: function () {
|
||||
return 'xo-cli version '+ require('../package').version;
|
||||
},
|
||||
})
|
||||
.parse(argv)
|
||||
;
|
||||
|
||||
if (opts.version)
|
||||
{
|
||||
return 'xo-cli version '+ require('../package').version;
|
||||
}
|
||||
|
||||
// Executes the selected command.
|
||||
Promise.try(command, [commandOpts]).then(function (value) {
|
||||
if (_.isString(value))
|
||||
{
|
||||
console.log(value);
|
||||
}
|
||||
|
||||
process.exit(0);
|
||||
}).catch(function (error) {
|
||||
if (error === undefined)
|
||||
{
|
||||
// Nothing to do.
|
||||
undefined;
|
||||
}
|
||||
else if (_.isNumber(error))
|
||||
{
|
||||
process.exit(error);
|
||||
}
|
||||
else
|
||||
{
|
||||
console.error(error.stack || error);
|
||||
}
|
||||
|
||||
process.exit(1);
|
||||
});
|
||||
return command(commandOpts);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user