Skip to content

refactor: replace strip-ansi with native node util #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Namchee
Copy link

@Namchee Namchee commented Aug 12, 2025

Overview

This pull request replaces strip-ansi dependency with native Node util stripVTControlCharacters that do the same thing.

This utility is available since Node 16.11

@shadowspawn
Copy link
Member

Oh, I didn't know there was a routine exposed from node. (I wrote one last year!)

I was bit concerned whether really does the same thing, as the node code is undocumented regex. However strip-ansi has a note:

Node.js has this built-in now with stripVTControlCharacters. The benefit of this package is consistent behavior across Node.js versions and faster improvements. The Node.js version is actually based on this package.

@shadowspawn
Copy link
Member

cliui is using the family of string-width, strip-ansi, and wrap-ansi. So we get self-consistent behaviour by using strip-ansi. Removing strip-ansi on its own makes no difference to install footprint, as still depended on by the other packages.

  "dependencies": {
    "string-width": "^7.2.0",
    "strip-ansi": "^7.1.0",
    "wrap-ansi": "^9.0.0"
  },

So I think the suggestion was reasonable, but I don't think it is useful at this time on its own.

Benjamin may have different view, so leaving PR open for second opinion.

@Namchee
Copy link
Author

Namchee commented Aug 14, 2025

Oh, I didn't know there was a routine exposed from node. (I wrote one last year!)

I was bit concerned whether really does the same thing, as the node code is undocumented regex. However strip-ansi has a note:

Node.js has this built-in now with stripVTControlCharacters. The benefit of this package is consistent behavior across Node.js versions and faster improvements. The Node.js version is actually based on this package.

Thanks for looking into this!

As for your concern, I have investigated this issue and I found out that it seems that the behaviour is consistent on Node 22.10 onwards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants