Nnodejs

nodejs/chalk-to-util-styletext

Migrate from the chalk package to Node.js's built-in util.styleText API

transformationmigration
Public
19 executions
3 stars
How to Use
Run this codemod on your codebase using one of the following commands

The easiest way to run this codemod without installing anything globally:

Documentation

Chalk to util.styleText

This recipe migrates from the external chalk package to Node.js built-in util.styleText API. It transforms chalk method calls to use the native Node.js styling functionality.

Examples

diff
diff
diff

Usage

Run this codemod with:

sh

Compatibility

  • Removes chalk dependency from package.json automatically
  • Supports most chalk methods: colors, background colors, and text modifiers
  • Unsupported methods: hex(), rgb(), ansi256(), bgAnsi256(), visible() (warnings will be shown)

Limitations

  • Complex conditional expressions in some contexts may need manual review
Before

This is one example from the codemod's test cases. The codemod may handle many more cases.

Ready to contribute?

Build your own codemod and share it with the community.