Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use picocolors for colored terminal output #409

Merged
merged 1 commit into from Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 7 additions & 5 deletions index.js
Expand Up @@ -6,7 +6,7 @@ import path from 'path'
import prettyHrtime from 'pretty-hrtime'
import stdin from 'get-stdin'
import read from 'read-cache'
import { bold, dim, red, cyan, green } from 'nanocolors'
import pc from 'picocolors'
import { globby } from 'globby'
import slash from 'slash'
import chokidar from 'chokidar'
Expand Down Expand Up @@ -118,7 +118,7 @@ buildCliConfig()
.then((results) => {
if (argv.watch) {
const printMessage = () =>
printVerbose(dim('\nWaiting for file changes...'))
printVerbose(pc.dim('\nWaiting for file changes...'))
const watcher = chokidar.watch(input.concat(dependencies(results)), {
usePolling: argv.poll,
interval: argv.poll && typeof argv.poll === 'number' ? argv.poll : 100,
Expand Down Expand Up @@ -213,7 +213,7 @@ function css(css, file) {

const time = process.hrtime()

printVerbose(cyan(`Processing ${bold(relativePath)}...`))
printVerbose(pc.cyan(`Processing ${pc.bold(relativePath)}...`))

return rc(ctx, argv.config)
.then((config) => {
Expand Down Expand Up @@ -261,7 +261,9 @@ function css(css, file) {
return Promise.all(tasks).then(() => {
const prettyTime = prettyHrtime(process.hrtime(time))
printVerbose(
green(`Finished ${bold(relativePath)} in ${bold(prettyTime)}`)
pc.green(
`Finished ${pc.bold(relativePath)} in ${pc.bold(prettyTime)}`
)
)

const messages = result.warnings()
Expand Down Expand Up @@ -316,7 +318,7 @@ function error(err) {
if (argv.verbose) console.error()

if (typeof err === 'string') {
console.error(red(err))
console.error(pc.red(err))
} else if (err.name === 'CssSyntaxError') {
console.error(err.toString())
} else {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -23,7 +23,7 @@
"fs-extra": "^10.0.0",
"get-stdin": "^9.0.0",
"globby": "^12.0.0",
"nanocolors": "^0.2.11",
"picocolors": "^1.0.0",
"postcss-load-config": "^3.0.0",
"postcss-reporter": "^7.0.0",
"pretty-hrtime": "^1.0.3",
Expand Down