prettyjson icon indicating copy to clipboard operation
prettyjson copied to clipboard

Switch `colors` to `chalk` - Fixes #57

Open fbartho opened this issue 4 years ago • 0 comments

This PR migrates prettyjson from colors to chalk - Related: #57 #54

This breaks support for the following "colors":

  • rainbow
  • zebra
  • america
  • trap
  • random
  • zalgo

These were present in colors.js and are not present in chalk

One of these "colors" (rainbow) is referenced in a unit test. Options: A. Delete the unit test B. Implement this color (and other alternative colors?) on top of chalk.js

Additionally, in chalk 5.x, they have gone ESM-only, so I pinned us to chalk @ 4.x -- chalk's 5.0 release links to Pure ESM

Features

  • Hex Color Support! "#FFFFFF"
  • options.unknownColorHandler by default warns users if a color isn't supported. This warning can be disabled via "ignore", or the user can provide a custom function to render a given input into the expected "color"
  • Allow overriding of true/false color via options.trueColor, options.falseColor
  • Allow overriding of null/undefined color via options.nullUndefinedColor

Remaining Tasks

  • [ ] Resolve the broken test / alternative-colors decision
  • [ ] Acknowledge chalk < 5 constraint, or decide how to proceed

fbartho avatar Jan 12 '22 22:01 fbartho