srs / gradle-node-plugin

Gradle plugin for integrating NodeJS in your build. :rocket:
Apache License 2.0
866 stars 211 forks source link

No colors in yarn tasks output #297

Open clemp6r opened 6 years ago

clemp6r commented 6 years ago

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

amimas commented 5 years ago

Any update on this yet?

mroloux commented 3 years ago

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

deepy commented 3 years ago

@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

mroloux commented 3 years ago

@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 ;-)

deepy commented 3 years ago

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' }
mroloux commented 3 years ago

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!

deepy commented 3 years ago

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

mroloux commented 3 years ago

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 🤔

deepy commented 3 years ago

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 :-)