Skip to content

Commit 8f64b29

Browse files
authored
feat: replace picocolors with ansis (#166)
1 parent 5d8ae32 commit 8f64b29

4 files changed

Lines changed: 18 additions & 12 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@types/minimist": "^1.2.5",
2121
"@types/node": "^22.10.0",
2222
"@typescript-eslint/parser": "^8.16.0",
23+
"ansis": "^3.12.0",
2324
"bumpp": "^9.8.1",
2425
"eslint": "^9.15.0",
2526
"eslint-plugin-case-police": "workspace:*",
@@ -33,7 +34,6 @@
3334
"minimist": "^1.2.8",
3435
"p-limit": "^6.1.0",
3536
"parse-gitignore": "^2.0.0",
36-
"picocolors": "^1.1.1",
3737
"pnpm": "^9.14.2",
3838
"rimraf": "^6.0.1",
3939
"typescript": "^5.7.2",

packages/case-police/src/cli.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { existsSync, promises as fs } from 'node:fs'
22
import process from 'node:process'
3+
import c from 'ansis'
34
import fg from 'fast-glob'
45
import isText from 'is-text-path'
56
import minimist from 'minimist'
67
import pLimit from 'p-limit'
7-
import c from 'picocolors'
88
// @ts-expect-error missing types
99
import parseIgnore from 'parse-gitignore'
1010
import { version } from '../package.json'
@@ -68,9 +68,9 @@ async function run() {
6868

6969
const limit = pLimit(5)
7070
console.log()
71-
console.log(c.inverse(c.red(' Case ')) + c.inverse(c.blue(' Police ')) + c.dim(` v${version}`))
71+
console.log(c.inverse.red(' Case ') + c.inverse.blue(' Police ') + c.dim` v${version}`)
7272
console.log()
73-
console.log(c.blue(files.length) + c.dim(' files found for checking, ') + c.cyan(Object.keys(dict).length) + c.dim(' words loaded\n'))
73+
console.log(c.blue(files.length) + c.dim` files found for checking, ${c.cyan(Object.keys(dict).length)} words loaded\n`)
7474
const wrote: string[] = []
7575
await Promise.all(files.map(file => limit(async () => {
7676
const code = await fs.readFile(file, 'utf-8')
@@ -90,8 +90,8 @@ async function run() {
9090
console.log(c.green('\nfiles fixed'))
9191
}
9292
else {
93-
console.log(c.dim(`\n${wrote.length} files contain case errors`))
94-
console.log(c.dim('run ') + c.magenta(c.bold('npx case-police --fix')) + c.dim(' to fix\n'))
93+
console.log(c.dim`\n${wrote.length} files contain case errors`)
94+
console.log(c.dim`run ${c.magenta.bold`npx case-police --fix`} to fix\n`)
9595
process.exitCode = 1
9696
}
9797
}

packages/case-police/src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable no-console */
22
import { existsSync, promises as fs } from 'node:fs'
33
import path from 'node:path'
4-
import c from 'picocolors'
4+
import c from 'ansis'
55
import { dictDir } from './dirs'
66

77
export type Presets = 'softwares' | 'products' | 'general' | 'brands' | 'abbreviates'
@@ -72,7 +72,7 @@ export async function replace(
7272
const lines = code.slice(0, offset).split('\n')
7373
const line = lines.length
7474
const col = (lines[line - 1].length || 0) + 1
75-
console.log(`${c.yellow(original)} ${c.dim('→')} ${c.green(replaced)} \t ${c.dim(`./${id}:${line}:${col}`)}`)
75+
console.log(c.yellow(original) + c.dim` → ${c.green(replaced)} ${'\t'} ./${id}:${line}:${col}`)
7676
}
7777

7878
return replaceCore(

pnpm-lock.yaml

Lines changed: 10 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)