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 Nov 10, 2021
1 parent 4860957 commit b2b0344
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 @@ -67,7 +67,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 @@ -79,6 +78,7 @@
"is-glob": "^4.0.3",
"normalize-path": "^3.0.0",
"object-hash": "^2.2.0",
"picocolors": "^1.0.0",
"postcss-js": "^3.0.3",
"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,25 +1,25 @@
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 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 b2b0344

Please sign in to comment.