Skip to content

Commit

Permalink
Replace chalk with picocolors
Browse files Browse the repository at this point in the history
Already used in latest postcss, autoprefixer and browserslist versions.

See https://github.com/alexeyraspopov/picocolors
  • Loading branch information
TrySound committed Jan 8, 2022
1 parent d06c9d6 commit 1797e14
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 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 @@ -65,7 +65,6 @@
},
"dependencies": {
"arg": "^5.0.1",
"chalk": "^4.1.2",
"chokidar": "^3.5.2",
"color-name": "^1.1.4",
"cosmiconfig": "^7.0.1",
Expand All @@ -77,6 +76,7 @@
"is-glob": "^4.0.3",
"normalize-path": "^3.0.0",
"object-hash": "^2.2.0",
"picocolors": "^1.0.0",
"postcss-js": "^4.0.0",
"postcss-load-config": "^3.1.0",
"postcss-nested": "5.0.6",
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
12 changes: 6 additions & 6 deletions src/util/log.js
@@ -1,15 +1,15 @@
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) {
Expand All @@ -18,12 +18,12 @@ export function 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 1797e14

Please sign in to comment.