MXS-1300: Resolved the promise for help commands
The promise returned by the `execute` MaxCtrl library function is now properly resolved also for `help` type commands.
This commit is contained in:
@ -102,7 +102,7 @@ module.exports.execute = function(argv, opts) {
|
|||||||
if (err) {
|
if (err) {
|
||||||
reject(err.message)
|
reject(err.message)
|
||||||
} else if (output) {
|
} else if (output) {
|
||||||
logger.log(output)
|
resolve(output)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -15,6 +15,12 @@
|
|||||||
|
|
||||||
var maxctrl = require('./lib/core.js')
|
var maxctrl = require('./lib/core.js')
|
||||||
|
|
||||||
|
function print(out) {
|
||||||
|
if (out) {
|
||||||
|
console.log(out)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Mangle the arguments if we are being called from the command line
|
// Mangle the arguments if we are being called from the command line
|
||||||
if (process.argv[0] == process.execPath) {
|
if (process.argv[0] == process.execPath) {
|
||||||
process.argv.shift()
|
process.argv.shift()
|
||||||
@ -23,12 +29,4 @@ if (process.argv[0] == process.execPath) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
maxctrl.execute(process.argv)
|
maxctrl.execute(process.argv)
|
||||||
.then(function(out) {
|
.then(print, print)
|
||||||
if (out) {
|
|
||||||
console.log(out)
|
|
||||||
}
|
|
||||||
}, function(out) {
|
|
||||||
if (out) {
|
|
||||||
console.log(out)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|||||||
@ -64,6 +64,12 @@ describe("Library invocation", function() {
|
|||||||
.should.be.rejected
|
.should.be.rejected
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('command help', function() {
|
||||||
|
var opts = { extra_args: [ '--quitet'] }
|
||||||
|
return ctrl.execute('help list'.split(' '), opts)
|
||||||
|
.should.be.fulfilled
|
||||||
|
})
|
||||||
|
|
||||||
it('connection failure', function() {
|
it('connection failure', function() {
|
||||||
stopMaxScale()
|
stopMaxScale()
|
||||||
.then(function() {
|
.then(function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user