Skip to content
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

isSupported returns true when redirecting stdout on windows #22

Closed
mdonnalley opened this issue Jul 22, 2024 · 4 comments
Closed

isSupported returns true when redirecting stdout on windows #22

mdonnalley opened this issue Jul 22, 2024 · 4 comments
Labels
bug Something isn't working
Milestone

Comments

@mdonnalley
Copy link

mdonnalley commented Jul 22, 2024

Current behaviour

On windows, ansis.isSupported() returns true when redirecting stdout to a file. On mac (and I'm assuming linux) it returns false.

This leads to ansi characters showing up in the file containing the redirected stdout. For example:

�[1mhello world�[22m

Expected behaviour

I expect ansis.isSupported() to return false when redirecting stdout to a file, regardless of operating system. This would be consistent with the supports-color package

Reproduction Example

git clone https://github.com/mdonnalley/ansis-bug.git
cd ansis-bug
npm install
node index.js > output.txt

On windows:

PS C:\Users\username\code\ansis-bug> node index.js > output.txt
PS C:\Users\username\code\ansis-bug> cat output.txt
ansis.isSupported true
supportsColor.stdout false

On mac:

❯ node index.js > output.txt
❯ cat output.txt
ansis.isSupported false
supportsColor.stdout false

Environment

  • OS: Windows
  • version of Node.js: 20.13.1
  • version of Webpack: NA
  • version of the Plugin: NA

Additional context

NA

@webdiscus webdiscus added the bug Something isn't working label Jul 22, 2024
@webdiscus webdiscus added this to the analysis milestone Jul 22, 2024
@webdiscus
Copy link
Owner

Hello @mdonnalley,

Thanks for the issue report. I will fix it.
What is Windows version: 10, 11, ... ?

@mdonnalley
Copy link
Author

@webdiscus thanks! I'm on Windows 11

webdiscus added a commit that referenced this issue Jul 23, 2024
- chore: optimize code to reduce the size by ~50 bytes
- chore: add benchmarks for `kolorist` package
- test: add test matrix for windows on GitHub
- docs: add compare the size of most popular packages
@webdiscus webdiscus modified the milestones: analysis, test Jul 23, 2024
@webdiscus
Copy link
Owner

@mdonnalley

the issue is fixed in the v3.3.2.
Can you please test it?

@mdonnalley
Copy link
Author

@webdiscus just tested and it's working as expected - thanks so much for quick turnaround!

@webdiscus webdiscus modified the milestones: test, done Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants