diff options
author | Gar <gar+gh@danger.computer> | 2022-04-11 02:26:55 +0300 |
---|---|---|
committer | Nathan Fritz <fritzy@github.com> | 2022-04-14 01:01:40 +0300 |
commit | c22fb1e756d43b54fefd826f2c3f459d4f1204b5 (patch) | |
tree | 8c18d5b9b0af4928452a6bcff11f124188ec32af /lib | |
parent | 605ccef6916c170f6d0c53775614f8a02682262a (diff) |
deps: remove ansicolors
Diffstat (limited to 'lib')
-rw-r--r-- | lib/commands/help-search.js | 4 | ||||
-rw-r--r-- | lib/commands/view.js | 49 |
2 files changed, 26 insertions, 27 deletions
diff --git a/lib/commands/help-search.js b/lib/commands/help-search.js index 3387ac8eb..23b426eaa 100644 --- a/lib/commands/help-search.js +++ b/lib/commands/help-search.js @@ -1,6 +1,6 @@ const fs = require('fs') const path = require('path') -const color = require('ansicolors') +const chalk = require('chalk') const { promisify } = require('util') const glob = promisify(require('glob')) const readFile = promisify(fs.readFile) @@ -173,7 +173,7 @@ class HelpSearch extends BaseCommand { for (const f of finder) { hilitLine.push(line.slice(p, p + f.length)) const word = line.slice(p + f.length, p + f.length + arg.length) - const hilit = color.bgBlack(color.red(word)) + const hilit = chalk.bgBlack.red(word) hilitLine.push(hilit) p += f.length + arg.length } diff --git a/lib/commands/view.js b/lib/commands/view.js index afe4b2428..403d09d81 100644 --- a/lib/commands/view.js +++ b/lib/commands/view.js @@ -3,7 +3,6 @@ // npm view [pkg [pkg ...]] -const color = require('ansicolors') const chalk = require('chalk') const columns = require('cli-columns') const fs = require('fs') @@ -318,34 +317,34 @@ class View extends BaseCommand { Object.keys(packument['dist-tags']).forEach((t) => { const version = packument['dist-tags'][t] - tags.push(`${chalk.bold(color.green(t))}: ${version}`) + tags.push(`${chalk.bold.green(t)}: ${version}`) }) const unpackedSize = manifest.dist.unpackedSize && formatBytes(manifest.dist.unpackedSize, true) const licenseField = manifest.license || 'Proprietary' const info = { - name: color.green(manifest.name), - version: color.green(manifest.version), - bins: Object.keys(manifest.bin || {}).map(color.yellow), - versions: color.yellow(packument.versions.length + ''), + name: chalk.green(manifest.name), + version: chalk.green(manifest.version), + bins: Object.keys(manifest.bin || {}), + versions: chalk.yellow(packument.versions.length + ''), description: manifest.description, deprecated: manifest.deprecated, - keywords: (packument.keywords || []).map(color.yellow), + keywords: packument.keywords || [], license: typeof licenseField === 'string' ? licenseField : (licenseField.type || 'Proprietary'), deps: Object.keys(manifest.dependencies || {}).map((dep) => { - return `${color.yellow(dep)}: ${manifest.dependencies[dep]}` + return `${chalk.yellow(dep)}: ${manifest.dependencies[dep]}` }), publisher: manifest._npmUser && unparsePerson({ - name: color.yellow(manifest._npmUser.name), - email: color.cyan(manifest._npmUser.email), + name: chalk.yellow(manifest._npmUser.name), + email: chalk.cyan(manifest._npmUser.email), }), modified: !packument.time ? undefined - : color.yellow(relativeDate(packument.time[manifest.version])), + : chalk.yellow(relativeDate(packument.time[manifest.version])), maintainers: (packument.maintainers || []).map((u) => unparsePerson({ - name: color.yellow(u.name), - email: color.cyan(u.email), + name: chalk.yellow(u.name), + email: chalk.cyan(u.email), })), repo: ( manifest.bugs && (manifest.bugs.url || manifest.bugs) @@ -356,47 +355,47 @@ class View extends BaseCommand { manifest.homepage && (manifest.homepage.url || manifest.homepage) ), tags, - tarball: color.cyan(manifest.dist.tarball), - shasum: color.yellow(manifest.dist.shasum), + tarball: chalk.cyan(manifest.dist.tarball), + shasum: chalk.yellow(manifest.dist.shasum), integrity: - manifest.dist.integrity && color.yellow(manifest.dist.integrity), + manifest.dist.integrity && chalk.yellow(manifest.dist.integrity), fileCount: - manifest.dist.fileCount && color.yellow(manifest.dist.fileCount), - unpackedSize: unpackedSize && color.yellow(unpackedSize), + manifest.dist.fileCount && chalk.yellow(manifest.dist.fileCount), + unpackedSize: unpackedSize && chalk.yellow(unpackedSize), } if (info.license.toLowerCase().trim() === 'proprietary') { - info.license = chalk.bold(color.red(info.license)) + info.license = chalk.bold.red(info.license) } else { - info.license = color.green(info.license) + info.license = chalk.green(info.license) } console.log('') console.log( chalk.underline.bold(`${info.name}@${info.version}`) + ' | ' + info.license + - ' | deps: ' + (info.deps.length ? color.cyan(info.deps.length) : color.green('none')) + + ' | deps: ' + (info.deps.length ? chalk.cyan(info.deps.length) : chalk.green('none')) + ' | versions: ' + info.versions ) info.description && console.log(info.description) if (info.repo || info.site) { - info.site && console.log(color.cyan(info.site)) + info.site && console.log(chalk.cyan(info.site)) } const warningSign = unicode ? ' ⚠️ ' : '!!' info.deprecated && console.log( - `\n${chalk.bold(color.red('DEPRECATED'))}${ + `\n${chalk.bold.red('DEPRECATED')}${ warningSign } - ${info.deprecated}` ) if (info.keywords.length) { console.log('') - console.log('keywords:', info.keywords.join(', ')) + console.log('keywords:', chalk.yellow(info.keywords.join(', '))) } if (info.bins.length) { console.log('') - console.log('bin:', info.bins.join(', ')) + console.log('bin:', chalk.yellow(info.bins.join(', '))) } console.log('') |