Skip to content

Commit

Permalink
Replace chalk with picocolors (#6039)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
TrySound and bradlc committed Feb 24, 2022
1 parent 04686b8 commit 2dec564
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
14 changes: 12 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -61,7 +61,6 @@
},
"dependencies": {
"arg": "^5.0.1",
"chalk": "^4.1.2",
"chokidar": "^3.5.3",
"color-name": "^1.1.4",
"cosmiconfig": "^7.0.1",
Expand All @@ -73,6 +72,7 @@
"is-glob": "^4.0.3",
"normalize-path": "^3.0.0",
"object-hash": "^2.2.0",
"picocolors": "^1.0.0",
"postcss": "^8.4.6",
"postcss-js": "^4.0.0",
"postcss-load-config": "^3.1.3",
Expand Down
4 changes: 2 additions & 2 deletions src/featureFlags.js
@@ -1,4 +1,4 @@
import chalk from 'chalk'
import colors from 'picocolors'
import log from './util/log'

let defaults = {
Expand Down Expand Up @@ -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', [
Expand Down
14 changes: 7 additions & 7 deletions src/util/log.js
@@ -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]))
},
}

0 comments on commit 2dec564

Please sign in to comment.