CONNECT-platform / codedoc

Create beautiful modern documentation websites.
https://codedoc.cc
MIT License
427 stars 12 forks source link

Missing chalk colors from child process #21

Open TysonMN opened 4 years ago

TysonMN commented 4 years ago

This is a spin off from issue #17

Quoting https://github.com/CONNECT-platform/codedoc/issues/17#issue-635870911

2020-06-09_21-01-29_119_mintty

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... 2020-06-10_22-29-01_123_mintty

...but not for error messages from codedoc.

loreanvictor commented 4 years ago

@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.

loreanvictor commented 4 years ago

@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?

TysonMN commented 4 years ago

...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.

2020-06-11_09-04-57_125_cmd

TysonMN commented 4 years ago

@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.

loreanvictor commented 4 years ago

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
TysonMN commented 4 years ago

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.

2020-06-11_19-16-24_126_cmd

loreanvictor commented 4 years ago

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?

TysonMN commented 4 years ago

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.

loreanvictor commented 4 years ago

Let's keep this issue open to monitor the state of that issue in chalk.