codekingpro/portable-devtools
115k
1const { log, output } = require('proc-log')
2
3const outputError = ({ standard = [], verbose = [], error = [], summary = [], detail = [] }) => {
4 for (const line of standard) {
5 // Each output line is just a single string
6 output.standard(line)
7 }
8 for (const line of verbose) {
9 log.verbose(...line)
10 }
11 for (const line of [...error, ...summary, ...detail]) {
12 log.error(...line)
13 }
14}
15
16const jsonError = (error, npm) => {
17 if (error && npm?.loaded && npm?.config.get('json')) {
18 return {
19 code: error.code,
20 summary: (error.summary || []).map(l => l.slice(1).join(' ')).join('\n').trim(),
21 detail: (error.detail || []).map(l => l.slice(1).join(' ')).join('\n').trim(),
22 ...error.json,
23 }
24 }
25}
26
27module.exports = {
28 outputError,
29 jsonError,
30}
31 