Replace chalk with picocolors (#6039)

* Replace chalk with picocolors

Already used in latest postcss, autoprefixer and browserslist versions.

See https://github.com/alexeyraspopov/picocolors

* Update `dim` function

Co-authored-by: Brad Cornes <bradlc41@gmail.com>
This commit is contained in:
Bogdan Chadkin 2022-02-24 19:37:31 +03:00 • committed by GitHub
parent 04686b8a05
commit 2dec5649c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 12 deletions

View file

@ -1,4 +1,4 @@
import chalk from 'chalk'
import colors from 'picocolors'
import log from './util/log'
let defaults = {
@ -41,7 +41,7 @@ export function issueFlagNotices(config) {
if (experimentalFlagsEnabled(config).length > 0) {
let changes = experimentalFlagsEnabled(config)
.map((s) => chalk.yellow(s))
.map((s) => colors.yellow(s))
.join(', ')
log.warn('experimental-flags-enabled', [

View file

@ -1,29 +1,29 @@
import chalk from 'chalk'
import colors from 'picocolors'
let alreadyShown = new Set()
function log(chalk, messages, key) {
function log(type, messages, key) {
if (process.env.JEST_WORKER_ID !== undefined) return
if (key && alreadyShown.has(key)) return
if (key) alreadyShown.add(key)
console.warn('')
messages.forEach((message) => console.warn(chalk, '-', message))
messages.forEach((message) => console.warn(type, '-', message))
}
export function dim(input) {
return chalk.dim(input)
return colors.dim(input)
}
export default {
info(key, messages) {
log(chalk.bold.cyan('info'), ...(Array.isArray(key) ? [key] : [messages, key]))
log(colors.bold(colors.cyan('info')), ...(Array.isArray(key) ? [key] : [messages, key]))
},
warn(key, messages) {
log(chalk.bold.yellow('warn'), ...(Array.isArray(key) ? [key] : [messages, key]))
log(colors.bold(colors.yellow('warn')), ...(Array.isArray(key) ? [key] : [messages, key]))
},
risk(key, messages) {
log(chalk.bold.magenta('risk'), ...(Array.isArray(key) ? [key] : [messages, key]))
log(colors.bold(colors.magenta('risk')), ...(Array.isArray(key) ? [key] : [messages, key]))
},
}