Git Product home page Git Product logo

Comments (2)

Qix- avatar Qix- commented on May 26, 2024 1

We can't detect this reliably, unfortunately. The way that TTYs are modelled makes the "is this a TTY whereby I can emit colors" check very fragile to begin with, and the last thing you want is to pipe the output into a program that is doing something with the output in some meaningful way, as the color codes will almost certainly break it.

Unfortunately your problem is exactly why that environment variable exists. However if you're using npm or otherwise have a package.json typically put that sort of thing in the scripts there. If you're not, and this is for something in production, you'll have to set up a pseudoterminal, which is anything but straightforward.

If you do end up putting it in a script, I'd suggest prefixing it with env, as in env DEBUG_COLORS=1 DEBUG='*' ... for a bit more robustness.

Sorry I couldn't give you a better answer :/

from debug.

adam-nielsen avatar adam-nielsen commented on May 26, 2024 1

No problem at all, thanks for the quick response! A shame there's no way to detect it reliably but as you say, perhaps it is better to err on the side of caution than to provide output filled with escape codes when they are not supported.

As you suggested, I ended up putting the workaround in package.json as:

"scripts": {
   "test": "DEBUG='*' DEBUG_COLORS=1 tsx --test"
}

And so far so good, so I'll continue with that workaround.

Thanks again!

from debug.

Related Issues (20)

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.