| 42 | } |
| 43 | |
| 44 | const formatWithOptions = ({ prefix: prefixes = [], eol = '\n', redact = true, ...options }, ...args) => { |
| 45 | const prefix = prefixes.filter(p => p != null).join(' ') |
| 46 | let formatted = STRIP_C01(baseFormatWithOptions(options, ...args)) |
| 47 | if (redact) { |
| 48 | formatted = redactLog(formatted) |
| 49 | } |
| 50 | // Splitting could be changed to only `\n` once we are sure we only emit unix newlines. |
| 51 | // The eol param to this function will put the correct newlines in place for the returned string. |
| 52 | const lines = formatted.split(/\r?\n/) |
| 53 | return lines.reduce((acc, l) => `${acc}${prefix}${prefix && l ? ' ' : ''}${l}${eol}`, '') |
| 54 | } |
| 55 | |
| 56 | module.exports = { formatWithOptions } |