codedoc
codedoc copied to clipboard
Missing chalk colors from child process
This is a spin off from issue #17
Quoting https://github.com/CONNECT-platform/codedoc/issues/17#issue-635870911
On the topic of error messages, where are those beautiful colors? My error message doesn't have any red in it :(
I am using Windows. I use GitKraken to launch a terminal. It opens Mintty 2.9.6.
There are many colors just above each prompt...
...but not for error messages from codedoc.
@bender2k14 it would be really great if you could clone the cli code locally and investigate this issue a bit further. this should be particularly related to this part of the CLI code.
@bender2k14 p.s. tested on Windows 7 default Command Prompt and the colors are working relatively fine (the color palette seems to be more limited). could you also test on the Command Prompt and see if you do not see any colors?
P.S. perhaps this is related to this issue?
...could you also test on the Command Prompt and see if you do not see any colors?
Here is the standard Windows Command Prompt. There are some green #
, but no red in the error message.
@bender2k14 it would be really great if you could clone the cli code locally and investigate this issue a bit further. this should be particularly related to this part of the CLI code.
Absolutely.
What makes you think that code is related to this bug...what should I be looking for? I don't see anything there to do with color.
How can I test my changes? My best guess was to start by executing node index.js
in the root of the repo, but that didn't work. I know that I want to test executing a line of code like
https://github.com/CONNECT-platform/codedoc/blob/030ba14c362b1b4cbc3f8ed2d9977aaf56862034/src/serve/index.ts#L73
I just need a bit more direction since this is not my normal programming environment.
because thats the main utility function running sub-commands and piping their output to the standard output. colors disappearing means some form of transformation happening on the output of those sub-commands while being piped.
the way I typically test the CLI is to run it from the root of another codedoc project, testing out its various commands. something like this:
node ../codedoc-cli/src/index.js update
Lots of colors from these two commands, including a red error, from the Windows default Command Prompt. So red missing from errors for missing files when executing serve
and all colors missing when using Mintty 2.9.6.
So red missing from errors for missing files when executing serve
setting Mintty aside, based on what you describe it seems like logs from the main CLI process preserve color while logs from sub-processes don't. perhaps some information is being lost in these two lines?
Yes, I think you are right.
To summarize, these two lines pipe the output of a child process to the output of the parent process, but the colors don't come with. That is exactly issue #381 of chalk.
Let's keep this issue open to monitor the state of that issue in chalk.