UNPKG

789 BJavaScriptView Raw
1import colors from 'picocolors'
2
3let alreadyShown = new Set()
4
5function log(type, messages, key) {
6 if (typeof process !== 'undefined' && process.env.JEST_WORKER_ID) return
7
8 if (key && alreadyShown.has(key)) return
9 if (key) alreadyShown.add(key)
10
11 console.warn('')
12 messages.forEach((message) => console.warn(type, '-', message))
13}
14
15export function dim(input) {
16 return colors.dim(input)
17}
18
19export default {
20 info(key, messages) {
21 log(colors.bold(colors.cyan('info')), ...(Array.isArray(key) ? [key] : [messages, key]))
22 },
23 warn(key, messages) {
24 log(colors.bold(colors.yellow('warn')), ...(Array.isArray(key) ? [key] : [messages, key]))
25 },
26 risk(key, messages) {
27 log(colors.bold(colors.magenta('risk')), ...(Array.isArray(key) ? [key] : [messages, key]))
28 },
29}