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

Automatic color detection issue on Windows with GIT Bash #163

Closed
Neonit opened this issue May 22, 2018 · 4 comments
Closed

Automatic color detection issue on Windows with GIT Bash #163

Neonit opened this issue May 22, 2018 · 4 comments

Comments

@Neonit
Copy link

Neonit commented May 22, 2018

Five minutes ago I didn't even know gulp had color support. I found this by running gulp manually:
node node_modules/gulp/bin/gulp.js
This gave me a colored output on my GIT Bash on Windows 7 x64.

The bash itself reports the following version:

GNU bash, version 4.3.42(5)-release (x86_64-pc-msys)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

Just running gulp (using the globally installed gulp-cli 2.0.1) does not give me a colored output. It works when I add --color manually. I have not installed gulp globally. My local gulp version is 4.0.0.

Further I'm using Node 10.0.0 and npm 5.6.0.

I would have tried to workaround this by adding the color flag to the global gulp-cli configuration, but the documentation states there is no color flag for the configuration file.

@sttk
Copy link
Contributor

sttk commented May 22, 2018

Thank you for the report.

I reproduced it but I don't find the cause yet, but I think it is not a gulp issue.
I'll look into it more.

$ npm i gulp-cli gulp@4
$ node -v
$ node_modules/.bin/gulp -v   // output with no color.
[05:21:19] CLI version 2.0.1
[05:21:19] Local version 4.0.0

$ node node_modules/gulp/bin/gulp.js -v // output with color.
[05:21:27] CLI version 2.0.1
[05:21:27] Local version 4.0.0

$ node_modules/gulp/bin/gulp.js -v // output with color.
[05:21:36] CLI version 2.0.1
[05:21:36] Local version 4.0.0

@sttk
Copy link
Contributor

sttk commented May 22, 2018

I found the cause of this issue.

gulp-cli uses color-support to detect whether a terminal supports color output, and it checks whether stdout is a TTY by process.stdout.isTTY.

However, this isTTY flag on MinGW is false, maybe because MinTTY does not play well with Windows console applications which need interactive mode.

We will not solve this issue in gulp-cli.

In additon, color flag in configuration file is not supported now.

Please work around this issue by using alias command, etc.

@sttk sttk closed this as completed May 22, 2018
@Neonit
Copy link
Author

Neonit commented May 23, 2018

I cannot reproduce your findings.

Using the same GIT Bash I encountered the issue with in the directory I cloned gulp-cli to (so I assume it's using the same version of color-support):

Me@Neonit MINGW64 /z/repositories/gulp-cli (master)
$ node -p -e "Boolean(process.stdout.isTTY)"
true

Me@Neonit MINGW64 /z/repositories/gulp-cli (master)
$ node -p -e "require('color-support')()"
{ level: 1, hasBasic: true, has256: false, has16m: false }

Ironically, the output was colored.

I had a look at your code in lib/shared/ansi.js and considering the above output I cannot understand how it doesn't want to give me colors by default.

@sttk
Copy link
Contributor

sttk commented May 23, 2018

@Neonit Use not node but node.exe.
I don't know mechanism inside of Git Bash Terminal, but these two commands behave differently, and gulp (and other applications?) runs with node.exe.

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

No branches or pull requests

2 participants