-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Pipe-redirecting Grunt's output is broken #510
Comments
You can use the |
@shama Thanks for the comment. However the problem remains -- no colors are output, but still I get only the first line while redirecting to
whereas when I redirect output to a file, it's fine:
Open out.txt in Notepad++:
|
@jakub-g Strange. I'll try on my Windows machine when I get it up and running. Not seeing that issue with OSX and Ubuntu. |
Some more findings after checking on my machines at home: WinXP Professional SP3 32bit + Git 1.7.11 shell -- like above Perhaps it's a MINGW32 thing, but I've been using Git from command line for a couple of months without any issues for cating, diffing etc. |
It's a bug in node in Windows where stdout/stderr isn't flushed properly prior to exiting the process. See nodejs/node-v0.x-archive#3584 . FWIW I work around this in the meantime by doing grunt.cmd --no-color > grunt.tmp & type grunt.tmp & del grunt.tmp |
Can you try grunt 0.4.0rc4? I'm pretty sure the problem is fixed there. |
I got it fixed by using the workaround @dcherman suggested (pipe to a file), is far from ideal, but it works |
the problem is still in grunt 0.4.0rc7. This is the output for a failing jshint task: Running:
If i don't pipe to more, then I get the full output with all my jshint errors |
While working on |
On windows I found that using powershell (instead of .bat) can solve this problem too. (and --no-color too) |
as @dcherman points out this is clearly not related to grunt, I have seen the same behavior when using npm and other node.js apps. |
#708 contains detailed info on the problem and a workaround code for this. |
I do remember seeing this problem in npm a while back, but it seems to have been fixed. Perhaps we should see how they fixed it and follow suit. I know that apps that use process.exit to abort execution often suffer from this. |
It seems that Grunt.js development is dead. Very annoying bug. Thanks for fix to Adam. But what about merge? |
Why grunt is not using By running: $ grunt sometask
$ grunt sometask | cat The first should output colors, the second none, out-of-the-box. Then, it could provide a |
I'm using this workaround to remove color output while piping. Doesn't work for other ansi codes like BEEP though. Unfortunately node streams don't have a flush method, or else the same monkey patch could be used to shim synchronous writes:
edit: since I can't seem to make this approach work for the lack of flushing a simpler approach can be done just to remove color/beeps:
|
This issue should be fixed via #921 |
I'm not 100% sure the source of the problem is Grunt, but since Unix tools are rather thoroughly tested, I thought I'll start from reporting here. Can someone try to reproduce on their machines?
Version: 0.3.17
I do everything under WinXP/MINGW32 (Git 1.7.11) sh console.
Let's create a simple grunt file
grunttest.js
:Let's run it:
Prints fine, all-white (standard text color).
Let's redirect to a file:
Open out.txt in Notepad++:
These are escape codes used to color the output. (Notepad++ additionally prints the ESC chars before the left-braces: char 27, or 0x1B, I deleted them since it was breaking the Markdown processor).
cat out.txt
actually produces a nice ASCII out of it, just like the first command, but colored.The interesting starts now:
When I want to pipe to
cat
orless
, I only see the first line (in cyan). I don't see the other lines. The above yields the same BTW:I'm pretty sure it's not a feature ;) Can someone confirm my findings? Any guesses what the problem might be?
I've tried a simple Node.js code (a few
console.log
s) and it works fine on the contrary. So it seems that Grunt + colored output are the cause.The text was updated successfully, but these errors were encountered: