Closed pajtai closed 6 years ago
By the time it reaches the prettifier (pino
) there is no color.
Try the following: nodemon index.js --exec 'npm run lint && node' | cat
You should see that there's no color, because generally CLI tools that output
color will check process.stdout.isTTY
(or require('tty').isatty()
) and then
output the additional terminal codes (or not).
node -p process.stdout.isTTY
-> true
node -p process.stdout.isTTY | cat
-> undefined
Closing for now, but if you want to keep color through a pipe that's down to configuring which ever libs are outputting colour (if they have that option)
@davidmarkclements Thanks for that info.
And sure enough, eslint has a --color
option that forces color even if isTTY is falsey.
I'll add my config here to preserve eslint colors through a pipe for anyone else who might find it helpful:
"scripts": {
"dev": "nodemon index.js --exec 'npm run lint && node' | pino",
"lint": "eslint --color ."
},
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Greater logger! I have a question:
I'm piping to the pino cli to parse and colorize Pino logs, but I sometimes have other output that comes with colors, and the pino cli removes these colors.
For example, I use eslint - which has colored output - how can I preserve that?
Example command
nodemon index.js --exec 'npm run lint && node' | pino