gradle-node-plugin icon indicating copy to clipboard operation
gradle-node-plugin copied to clipboard

No colors in yarn tasks output

Open clemp6r opened this issue 6 years ago • 9 comments

When running Yarn tasks using this gradle plugin, I get no colors in the output. Running the same commands using Yarn directly prints colorized text.

e.g:

./gradlew yarn_list : all text is white

vs.

yarn list : text is white and gray

clemp6r avatar May 04 '18 13:05 clemp6r

Any update on this yet?

amimas avatar Feb 08 '19 00:02 amimas

I'm running into this as well. Is there a way to enable colored output?

mroloux avatar Oct 08 '20 17:10 mroloux

@mroloux this plugin hasn't seen active development in a long while, there's however a maintained fork available.

But I also have a feeling that this wasn't an issue on Linux and with npm, so more information is probably required to solve this

deepy avatar Oct 08 '20 17:10 deepy

@deepy Thanks!

I assume this is the fork you're referring to? https://github.com/node-gradle/gradle-node-plugin

Seems like it has the same issue - no colored output. Guess we'll have to live without it then ;-)

mroloux avatar Oct 08 '20 18:10 mroloux

That's the one yeah, though for coloured output there might be a way to force yarn/npm to do coloured output.

You could try adding --color=full into args and see if that helps.

Something like:

tasks.named('yarn_list').configure { args += '--color=full' }

deepy avatar Oct 08 '20 18:10 deepy

When I execute yarn run tsc (outside of Gradle), the colors are printed just fine. So it must be related to how Gradle handles the output of yarn.

I've tried add --color=full, but that doesn't seem to be a supported parameter.

Also tried --console=rich, but that didn't make a difference.

Thanks for the help!

mroloux avatar Oct 08 '20 20:10 mroloux

This issue has some variations that might be worth trying https://github.com/yarnpkg/yarn/issues/5733

deepy avatar Oct 08 '20 21:10 deepy

Yes, FORCE_COLOR=true did the trick! Thanks so much!

I also added the --pretty flag to the tsc command, to get nicely colored errors from TypeScript. And --colors to prettify Jest.

Who would have known that Yarn, tsc and Jest would behave so differently within Gradle 🤔

mroloux avatar Oct 08 '20 21:10 mroloux

Most tools do when the output isn't a tty, you can simulate it by doing yarn install | cat, but I'm glad you managed to get it working :-)

deepy avatar Oct 15 '20 14:10 deepy