Comments (2)
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.
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)
- debug with dotenv HOT 3
- INEFFICIENT REGULAR EXPRESSION COMPLEXITY IN DEBUG HOT 1
- [Question] How do I enable millisecond diff?
- Issue in Next.js HOT 5
- Redirect logs to file doesnt capture time HOT 2
- Different formatting for namespaces on TTY and files
- Specify peer dependency version
- Specify namespace with url in ESM HOT 5
- npm ERR! code ENOENT npm ERR! syscall open npm ERR! path C:\Users\sahar\Desktop\myCode\jonas_React_course\React_Jonas_20_10_2023\project_pizza-menu\package.json npm ERR! errno -4058 npm ERR! enoent Could not read package.json: Error: ENOENT: no such file or directory, open 'C:\Users\sahar\Desktop\myCode\jonas_React_course\React_Jonas_20_10_2023\project_pizza-menu\package.json' npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent HOT 1
- Debug mixed with console.log HOT 6
- Debug Checkmarx Vulnerability HOT 1
- Avoid throwing errors
- useColors return false after modify user-agent in tauri app HOT 1
- Alternate solution to CWE-1333 | Inefficient Regular Expression Complexity
- Display full error object all the time regardless of argument position
- DEBUG_HIDE_DATE doesn't exist / do anything
- Property 'type' does not exist on type 'Process'.
- How to set max array length (`maxArrayLength`)? HOT 1
- update colors for darkmode in devtools
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from debug.