Skip to content

Force color output in rescript_bsb.js if NINJA_ANSI_FORCED=1 #7032

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

Closed
wants to merge 2 commits into from

Conversation

mediremi
Copy link
Contributor

When running rescript build as a child process, color output can be enabled with NINJA_ANSI_FORCED=1. However, rescript_bsb.js does not respect this environmental variable and instead decides whether to colorize its log output based on process.stdout.isTTY and process.stderr.isTTY.

This PR fixes this issue by making rescript_bsb.js colorize its stdout and stderr log output if NINJA_ANSI_FORCED=1.

@mediremi mediremi marked this pull request as ready for review September 11, 2024 13:52
@cknitt
Copy link
Member

cknitt commented Sep 11, 2024

Thank you for this PR! The changes look good to me. 👍

Probably out of scope for this PR, but I think it would make more sense from a user experience point of view to set a variable called something like RESCRIPT_FORCE_COLOR (or a similar command line flag) rather than NINJA_ANSI_FORCED. Especially as we are planning to move away from the ninja-based build system to rewatch.

@mediremi
Copy link
Contributor Author

mediremi commented Sep 11, 2024

Yup NINJA_ANSI_FORCED isn't the clearest name for this env var. What do you think about FORCE_COLOR, without the RESCRIPT_ prefix? It's what node.js and chalk use.

I've created a draft PR using FORCE_COLOR (but happy to use RESCRIPT_FORCE_COLOR instead) that would supersede this one: #7033

I've the approach in that PR seems good I'll close this one and continue work there 👍

@mediremi mediremi closed this Sep 12, 2024
@mediremi mediremi deleted the bsb-ninja-ansi-forced branch May 24, 2025 16:00
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.

2 participants