feat(cli): auto Promise.all

This commit is contained in:
Julien Fontanet 2017-06-08 15:11:01 +02:00
parent 22c515b0e7
commit 9c8ea27238

View File

@ -9,7 +9,7 @@ import execPromise from 'exec-promise'
import minimist from 'minimist'
import pw from 'pw'
import { asCallback, fromCallback } from 'promise-toolbox'
import { filter, find } from 'lodash'
import { filter, find, isArray } from 'lodash'
import { start as createRepl } from 'repl'
import { createClient } from './'
@ -92,7 +92,9 @@ const main = async args => {
repl.eval = (evaluate => (cmd, context, filename, cb) => {
fromCallback(cb => {
evaluate.call(repl, cmd, context, filename, cb)
})::asCallback(cb)
}).then(value =>
isArray(value) ? Promise.all(value) : value
)::asCallback(cb)
})(repl.eval)
await eventToPromise(repl, 'exit')