Skip to content

Commit

Permalink
Replace chalk with ansis
Browse files Browse the repository at this point in the history
  • Loading branch information
KristjanESPERANTO committed Dec 1, 2024
1 parent 2c13412 commit 60db541
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@pnpm/lockfile-file": "^7.0.6",
"@pnpm/logger": "5.1.0",
"@yarnpkg/lockfile": "^1.1.0",
"chalk": "^5.3.0",
"ansis": "^3.3.2",
"commander": "^11.1.0",
"fs-extra": "^11.2.0",
"node-fetch": "^3.3.2",
Expand Down
12 changes: 9 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/check.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { CommonOption, PackageInfo, PackageVersions, VersionOrRange } from './types'
import chalk from 'chalk'
import ansis from 'ansis'
import fetch from 'node-fetch'
import semver from 'semver'
import { recommendDependencies } from './chatgpt'
Expand Down Expand Up @@ -29,10 +29,10 @@ export async function checkDependencies(dependencies: Record<string, VersionOrRa
warn(`${result.name}@${result.version}: ${result.time}\ndeprecated: ${result.deprecated}`)

if (result.recommend) {
log(chalk.green('recommended: '))
log(ansis.green('recommended: '))
if (Array.isArray(result.recommend)) {
for (const packageName of result.recommend)
log(`[${chalk.magenta(packageName)}](https://www.npmjs.com/package/${packageName})`)
log(`[${ansis.magenta(packageName)}](https://www.npmjs.com/package/${packageName})`)
}
else {
log(result.recommend)
Expand Down
8 changes: 4 additions & 4 deletions src/utils/console.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/* eslint-disable no-console */
import chalk from 'chalk'
import ansis from 'ansis'

export function error(text?: string) {
console.error(`${chalk.bgRed(' ERROR ')} ${chalk.red(text ?? '')}`)
console.error(`${ansis.bgRed(' ERROR ')} ${ansis.red(text ?? '')}`)
}

export function log(text?: string) {
console.log(text ?? '')
}

export function ok(text?: string) {
console.log(`${chalk.bgGreen(' OK ')} ${text ?? ''}`)
console.log(`${ansis.bgGreen(' OK ')} ${text ?? ''}`)
}

export function warn(text?: string) {
console.warn(`${chalk.bgYellowBright(' WARN ')} ${chalk.yellow(text ?? '')}`)
console.warn(`${ansis.bgYellowBright(' WARN ')} ${ansis.yellow(text ?? '')}`)
}

0 comments on commit 60db541

Please sign in to comment.