33
44// npm view [pkg [pkg ...]]
55
6- const color = require ( 'ansicolors' )
76const chalk = require ( 'chalk' )
87const columns = require ( 'cli-columns' )
98const fs = require ( 'fs' )
@@ -318,34 +317,34 @@ class View extends BaseCommand {
318317
319318 Object . keys ( packument [ 'dist-tags' ] ) . forEach ( ( t ) => {
320319 const version = packument [ 'dist-tags' ] [ t ]
321- tags . push ( `${ chalk . bold ( color . green ( t ) ) } : ${ version } ` )
320+ tags . push ( `${ chalk . bold . green ( t ) } : ${ version } ` )
322321 } )
323322 const unpackedSize = manifest . dist . unpackedSize &&
324323 formatBytes ( manifest . dist . unpackedSize , true )
325324 const licenseField = manifest . license || 'Proprietary'
326325 const info = {
327- name : color . green ( manifest . name ) ,
328- version : color . green ( manifest . version ) ,
329- bins : Object . keys ( manifest . bin || { } ) . map ( color . yellow ) ,
330- versions : color . yellow ( packument . versions . length + '' ) ,
326+ name : chalk . green ( manifest . name ) ,
327+ version : chalk . green ( manifest . version ) ,
328+ bins : Object . keys ( manifest . bin || { } ) ,
329+ versions : chalk . yellow ( packument . versions . length + '' ) ,
331330 description : manifest . description ,
332331 deprecated : manifest . deprecated ,
333- keywords : ( packument . keywords || [ ] ) . map ( color . yellow ) ,
332+ keywords : packument . keywords || [ ] ,
334333 license : typeof licenseField === 'string'
335334 ? licenseField
336335 : ( licenseField . type || 'Proprietary' ) ,
337336 deps : Object . keys ( manifest . dependencies || { } ) . map ( ( dep ) => {
338- return `${ color . yellow ( dep ) } : ${ manifest . dependencies [ dep ] } `
337+ return `${ chalk . yellow ( dep ) } : ${ manifest . dependencies [ dep ] } `
339338 } ) ,
340339 publisher : manifest . _npmUser && unparsePerson ( {
341- name : color . yellow ( manifest . _npmUser . name ) ,
342- email : color . cyan ( manifest . _npmUser . email ) ,
340+ name : chalk . yellow ( manifest . _npmUser . name ) ,
341+ email : chalk . cyan ( manifest . _npmUser . email ) ,
343342 } ) ,
344343 modified : ! packument . time ? undefined
345- : color . yellow ( relativeDate ( packument . time [ manifest . version ] ) ) ,
344+ : chalk . yellow ( relativeDate ( packument . time [ manifest . version ] ) ) ,
346345 maintainers : ( packument . maintainers || [ ] ) . map ( ( u ) => unparsePerson ( {
347- name : color . yellow ( u . name ) ,
348- email : color . cyan ( u . email ) ,
346+ name : chalk . yellow ( u . name ) ,
347+ email : chalk . cyan ( u . email ) ,
349348 } ) ) ,
350349 repo : (
351350 manifest . bugs && ( manifest . bugs . url || manifest . bugs )
@@ -356,47 +355,47 @@ class View extends BaseCommand {
356355 manifest . homepage && ( manifest . homepage . url || manifest . homepage )
357356 ) ,
358357 tags,
359- tarball : color . cyan ( manifest . dist . tarball ) ,
360- shasum : color . yellow ( manifest . dist . shasum ) ,
358+ tarball : chalk . cyan ( manifest . dist . tarball ) ,
359+ shasum : chalk . yellow ( manifest . dist . shasum ) ,
361360 integrity :
362- manifest . dist . integrity && color . yellow ( manifest . dist . integrity ) ,
361+ manifest . dist . integrity && chalk . yellow ( manifest . dist . integrity ) ,
363362 fileCount :
364- manifest . dist . fileCount && color . yellow ( manifest . dist . fileCount ) ,
365- unpackedSize : unpackedSize && color . yellow ( unpackedSize ) ,
363+ manifest . dist . fileCount && chalk . yellow ( manifest . dist . fileCount ) ,
364+ unpackedSize : unpackedSize && chalk . yellow ( unpackedSize ) ,
366365 }
367366 if ( info . license . toLowerCase ( ) . trim ( ) === 'proprietary' ) {
368- info . license = chalk . bold ( color . red ( info . license ) )
367+ info . license = chalk . bold . red ( info . license )
369368 } else {
370- info . license = color . green ( info . license )
369+ info . license = chalk . green ( info . license )
371370 }
372371
373372 console . log ( '' )
374373 console . log (
375374 chalk . underline . bold ( `${ info . name } @${ info . version } ` ) +
376375 ' | ' + info . license +
377- ' | deps: ' + ( info . deps . length ? color . cyan ( info . deps . length ) : color . green ( 'none' ) ) +
376+ ' | deps: ' + ( info . deps . length ? chalk . cyan ( info . deps . length ) : chalk . green ( 'none' ) ) +
378377 ' | versions: ' + info . versions
379378 )
380379 info . description && console . log ( info . description )
381380 if ( info . repo || info . site ) {
382- info . site && console . log ( color . cyan ( info . site ) )
381+ info . site && console . log ( chalk . cyan ( info . site ) )
383382 }
384383
385384 const warningSign = unicode ? ' ⚠️ ' : '!!'
386385 info . deprecated && console . log (
387- `\n${ chalk . bold ( color . red ( 'DEPRECATED' ) ) } ${
386+ `\n${ chalk . bold . red ( 'DEPRECATED' ) } ${
388387 warningSign
389388 } - ${ info . deprecated } `
390389 )
391390
392391 if ( info . keywords . length ) {
393392 console . log ( '' )
394- console . log ( 'keywords:' , info . keywords . join ( ', ' ) )
393+ console . log ( 'keywords:' , chalk . yellow ( info . keywords . join ( ', ' ) ) )
395394 }
396395
397396 if ( info . bins . length ) {
398397 console . log ( '' )
399- console . log ( 'bin:' , info . bins . join ( ', ' ) )
398+ console . log ( 'bin:' , chalk . yellow ( info . bins . join ( ', ' ) ) )
400399 }
401400
402401 console . log ( '' )
0 commit comments