Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not clobber forked process color level #1455

Closed
wants to merge 1 commit into from

Conversation

nowells
Copy link
Contributor

@nowells nowells commented Jul 15, 2017

Chalk uses supports-color to determine what color level should be
rendered. However, currently our parent ava process uses that to
colorize its output, however, when we fork our test processes we clobber
the color configuration that supports-color uses to determine the
level (see https://github.com/chalk/supports-color/blob/master/index.js#L37-L42)

This PR carries the current color level through to the forked processes
so if they log output that is colorized it will remain so with the same
fidelity of colors as the parent ava process.

Chalk uses `supports-color` to determine what color level should be
rendered. However, currently our parent `ava` process uses that to
colorize its output, however, when we fork our test processes we clobber
the color configuration that `supports-color` uses to determine the
level (see https://github.com/chalk/supports-color/blob/master/index.js#L37-L42)

This PR carries the current color level through to the forked processes
so if they log output that is colorized it will remain so with the same
fidelity of colors as the parent ava process.
@novemberborn
Copy link
Member

Interesting. #1401 aims to forward --color only if the user has explicitly provided it. See also the discussion in #1393.

Of course the forked processes still can't detect the color support, and we can't necessarily expect the user to know what to specify either. Does this mean we should provide a value for --color when the user provides it without a value in the ava invocation?

@sindresorhus, @kevva?

@sindresorhus
Copy link
Member

Does this mean we should provide a value for --color when the user provides it without a value in the ava invocation?

Yes, the forked process should get the exact same color level as AVA.

@sindresorhus sindresorhus changed the title Do not clobber forked process color level. Do not clobber forked process color level Aug 12, 2017
@novemberborn
Copy link
Member

Does this mean we should provide a value for --color when the user provides it without a value in the ava invocation?

Yes, the forked process should get the exact same color level as AVA.

Re-reading my original comment I'm not exactly sure what I meant! I think the conclusion is:

  • Only pass --color to the worker process if it was provided to the main AVA process
  • If it was provided with a value, pass it exactly as used
  • If it was provided without a value, have AVA detect color support, and pass it with the appropriate value so that the worker process is configured with the same level of support

@sindresorhus did I get this right?

@sindresorhus
Copy link
Member

If it was provided without a value, have AVA detect color support, and pass it with the appropriate value so that the worker process is configured with the same level of support

This should also happen if no --color flag was provided.


And it should also pass the --no-color flag.

@novemberborn
Copy link
Member

If it was provided without a value, have AVA detect color support, and pass it with the appropriate value so that the worker process is configured with the same level of support

This should also happen if no --color flag was provided.

@sindresorhus that's not my understanding based on our discussion in #1401 (comment).

@sindresorhus
Copy link
Member

@novemberborn It should just work as if the child process was run in the same process as AVA.

@novemberborn
Copy link
Member

It should just work as if the child process was run in the same process as AVA.

Yes, but per #1393 we should only pass --color if it was provided to AVA. We need a different way of enabling colors if the flag was not provided. And I'm still not sure if we should rewrite the --color flag if it was provided to AVA without a value.

@novemberborn
Copy link
Member

#1700 clears up what arguments are exposed to the test worker. Let's discuss the specifics around configuring color in #1701.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants