The REPL waits for promise completion.

This commit is contained in:
Julien Fontanet 2015-04-21 17:20:38 +02:00
parent f0858b7d93
commit 7e8c2211d8

View File

@ -41,6 +41,18 @@ const main = coroutine(function * (args) {
prompt: `${xapi._humanId}> `
})
repl.context.xapi = xapi
// Make the REPL waits for promise completion.
{
const evaluate = Bluebird.promisify(repl.eval)
repl.eval = (cmd, context, filename, cb) => {
evaluate(cmd, context, filename)
// See https://github.com/petkaantonov/bluebird/issues/594
.then(result => result)
.nodeify(cb)
}
}
yield eventToPromise(repl, 'exit')
try {