UNPKG

430 BJavaScriptView Raw
1'use strict'
2
3/**
4 * Handle logging of listr `ctx.output` to the specified `logger`
5 * @param {Object} ctx - The listr initial state
6 * @param {Object} logger - The logger
7 */
8const printTaskOutput = (ctx = {}, logger) => {
9 if (!Array.isArray(ctx.output)) return
10 const log = ctx.errors && ctx.errors.size > 0 ? logger.error : logger.log
11 for (const line of ctx.output) {
12 log(line)
13 }
14}
15
16module.exports = printTaskOutput