sindresorhus / grunt-concurrent

Run grunt tasks concurrently

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Output still not colorized

ficristo opened this issue · comments

I tried the last version (2.1.0) on the project on which I work and the output is still not colorized.
(Running the tests of my fork of grunt-concurrent they all pass.)
If I change stdio option back to the string inherit the output is colorized but I get Warning: Cannot call method 'pipe' of null Use --force to continue.
If I comment the block with if (opts.logConcurrentOutput) everything seems to work correctly.
I don't know how to solve this issue.

Dang, I don't own any iDevice :/ (Win user here)

Will try looking at it later on Ubuntu VM, maybe the problem occurs on other *nix systems.

I tried on a Windows machine and even there the output is still not colorized.

@ficristo
Oups, that seems like something more complicated.
What's your setup? (versions, grunt-concurrent config, terminal)

If you could test on Windows, it would be helpful to me.

@ficristo
Is the problem still occuring? Could you provide some info about that?

@fatfisz The problem is still occuring.
The setup of the OSX machine is a bit complex but the relevant parts are:

  • node 0.10.x (I'm not on the machine and do not remember the precise version)
  • grunt 0.4.5
  • grunt-concurrent 2.1.0
  • grunt-nodemon 0.3.0 (I tried with 0.4.0 too)
  • grunt-watch (I think the latest available)
  • debug 2.2.0 https://github.com/visionmedia/debug
  • OSX terminal

This check on the debug module seems to return false instead of true:
tty.isatty(fd) https://github.com/visionmedia/debug/blob/master/node.js#L47

Switching back to grunt-concurrent 1.0.1 fix the problem.

I'll try to found some time to replicate on a windows machine.

The following will print the debug message colorized with grunt-concurrent 1.0.1 version and not with the 2.1.0 one.
I tested this on Windows with a MINGW64 terminal (the one that come with git bash).

To run: DEBUG=* grunt

package.json

{
  "name": "grunt-concurrent-test",
  "private": true,
  "dependencies": {
    "debug": "2.2.0"
  },
  "devDependencies": {
    "grunt": "0.4.5",
    "grunt-concurrent": "2.1.0",
    "grunt-nodemon": "0.4.0"
  }
}

server.js

var debug = require('debug')('server');

debug('debug');
console.log('console.log');

gruntfile.js

module.exports = function (grunt) {
    grunt.initConfig({
        concurrent: {
            log: {
                options: {
                    logConcurrentOutput: true
                },
                tasks: ['nodemon']
            }
        },
        nodemon: {
            dev: {
                script: 'server.js'
            }
        }
    });

    grunt.loadNpmTasks('grunt-nodemon');
    grunt.loadNpmTasks('grunt-concurrent');

    grunt.registerTask('default', [
        'concurrent'
    ]);
};

I guess you aren't seeing anything like that? :(
image

Package versions:

grunt-concurrent-test@ d:\Projects\grunt-concurrent-test
├── debug@2.2.0
├── grunt@0.4.5
├── grunt-concurrent@2.1.0
└── grunt-nodemon@0.4.0

Which Windows version were you testing on? Mine is 10.

Oh wait, the problem only occurs with the debug package?
debug doesn't receive any information about the environment grunt-concurrent runs in (because of the piping), so tty.isatty should return false, and rightly so.

I suggest using the answer from the file you've linked: set the DEBUG_COLORS env var to something.
My result after setting DEBUG to * and DEBUG_COLORS to 1 (as seen in cmd):
image

@fatfisz You are right, adding the DEBUG_COLORS env variable made it works.
It is a bit of a shame this behaviour changed, but now I have a workaround feel free to close the issue.
Thank you for the patience.

This is a trade-off for the output padding, which requires piping the data to the intermediary transformer, and only then to stdout / stderr.

I think this could be documented - I will create a PR for that. Thanks for your cooperation!

Btw. I can't close this issue, so it's either you or @sindresorhus ;)