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