GithubHelp home page GithubHelp logo

Color detection when using PM2 about ansis HOT 7 CLOSED

RobinTail avatar RobinTail commented on July 28, 2024 1
Color detection when using PM2

from ansis.

Comments (7)

webdiscus avatar webdiscus commented on July 28, 2024 2

I know that the size of ansis is important for you

This is important not so much for me as for the developers who compare many libs and one of the most important criterion is the size :-)

Your implementation adds to dist only 29 bytes, perfect!
Thank You so much!

I will publish new package now.

from ansis.

RobinTail avatar RobinTail commented on July 28, 2024 1

I know that the size of ansis is important for you, so I'm not pushing for any particular implementation, @webdiscus
Therefore, I just want to convey the idea that isTTY is missing in PM2 case, but the actual terminal can still support colors.

from ansis.

RobinTail avatar RobinTail commented on July 28, 2024 1

Or, maybe the exception could be made here, @webdiscus (probably more readable):

 const isTTY = isNextJS || isPM2 || (isDeno ? Deno.isatty(1) : stdout && 'isTTY' in stdout); 

from ansis.

RobinTail avatar RobinTail commented on July 28, 2024 1

I collected all my suggestions and ideas in PR #20 , including tests, @webdiscus .
I tested it manually on my machine using local build and linked references.
And it works.

from ansis.

webdiscus avatar webdiscus commented on July 28, 2024 1

@RobinTail

The version 3.1.0 has been released with PM2 support.
Thanks!

from ansis.

webdiscus avatar webdiscus commented on July 28, 2024

Hello @RobinTail

thanks for the feature request.
I will add the supports for PM2.

How many colors does PM2, truecolor, 256, 16 support?

from ansis.

RobinTail avatar RobinTail commented on July 28, 2024

It should depend on the actual terminal, meaning that the lines AFTER the line 47 (isTTY condition) should be executed

// terminals, that support truecolor, e.g., iTerm, VSCode
if (colorterm === 'truecolor' || colorterm === '24bit') return SPACE_TRUE_COLORS;
// kitty is GPU based terminal emulator
if (term === 'xterm-kitty') return SPACE_TRUE_COLORS;
// JetBrains IDEA: JetBrains-JediTerm
// TODO: enable truecolor output in IDEA (defaults output 256 colors) if anybody need it
//if (env.TERMINAL_EMULATOR?.include('JediTerm')) return SPACE_TRUE_COLORS;
// note: check for 256 colors after ENV variables such as TERM, COLORTERM, TERMINAL_EMULATOR etc.
// terminals, that support 256 colors, e.g., native macOS terminal
if (/-256(colou?r)?$/i.test(term)) return SPACE_256_COLORS;
// known terminals supporting 16 colors
if (/^screen|^tmux|^xterm|^vt[1-5][0-9]([0-9])?|^ansi|color|cygwin|linux|mintty|rxvt/i.test(
term)) return SPACE_16_COLORS;
// note: for unknown terminals we allow truecolor output,
// because all terminals supporting only 16 or 256 colors have already been detected above
return SPACE_TRUE_COLORS;

Basically, the lack of isTTY should be ignored when PM2 is detected, @webdiscus

from ansis.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.