Skip to content

Commit 60b476d

Browse files
authored
refactor: replace chalk with colorette (postcss#365)
Since postcss and postcss-reporter use colorette, getting rid of chalk in this package saves about 100KB when doing a `yarn install`.
1 parent 947665b commit 60b476d

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const path = require('path')
66
const prettyHrtime = require('pretty-hrtime')
77
const stdin = require('get-stdin')
88
const read = require('read-cache')
9-
const chalk = require('chalk')
9+
const { bold, dim, red, cyan, green } = require('colorette')
1010
const globber = require('globby')
1111
const slash = require('slash')
1212
const chokidar = require('chokidar')
@@ -106,7 +106,7 @@ Promise.resolve()
106106
.then((results) => {
107107
if (argv.watch) {
108108
const printMessage = () =>
109-
printVerbose(chalk.dim('\nWaiting for file changes...'))
109+
printVerbose(dim('\nWaiting for file changes...'))
110110
const watcher = chokidar.watch(input.concat(dependencies(results)), {
111111
usePolling: argv.poll,
112112
interval: argv.poll && typeof argv.poll === 'number' ? argv.poll : 100,
@@ -197,7 +197,7 @@ function css(css, file) {
197197

198198
const time = process.hrtime()
199199

200-
printVerbose(chalk`{cyan Processing {bold ${relativePath}}...}`)
200+
printVerbose(cyan(`Processing ${bold(relativePath)}...`))
201201

202202
return rc(ctx, argv.config)
203203
.then((config) => {
@@ -245,7 +245,7 @@ function css(css, file) {
245245
return Promise.all(tasks).then(() => {
246246
const prettyTime = prettyHrtime(process.hrtime(time))
247247
printVerbose(
248-
chalk`{green Finished {bold ${relativePath}} in {bold ${prettyTime}}}`
248+
green(`Finished ${bold(relativePath)} in ${bold(prettyTime)}`)
249249
)
250250

251251
const messages = result.warnings()
@@ -288,7 +288,7 @@ function error(err) {
288288
if (argv.verbose) console.error()
289289

290290
if (typeof err === 'string') {
291-
console.error(chalk.red(err))
291+
console.error(red(err))
292292
} else if (err.name === 'CssSyntaxError') {
293293
console.error(err.toString())
294294
} else {

lib/args.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict'
2-
const chalk = require('chalk')
2+
const { bold, red } = require('colorette')
33

44
const logo = `
55
/|\\
@@ -15,7 +15,7 @@ const logo = `
1515

1616
module.exports = require('yargs')
1717
.usage(
18-
`${chalk.bold.red(logo)}
18+
`${bold(red(logo))}
1919
Usage:
2020
$0 [input.css] [OPTIONS] [-o|--output output.css] [--watch|-w]
2121
$0 <input.css>... [OPTIONS] --dir <output-directory> [--watch|-w]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"test": "nyc ava -v"
1919
},
2020
"dependencies": {
21-
"chalk": "^4.0.0",
2221
"chokidar": "^3.3.0",
22+
"colorette": "^1.2.1",
2323
"dependency-graph": "^0.9.0",
2424
"fs-extra": "^9.0.0",
2525
"get-stdin": "^8.0.0",

0 commit comments

Comments
 (0)