dbushell / grunt-svg2png

Grunt plugin to rasterize SVG to PNG images using PhantomJS
MIT License
76 stars 37 forks source link

added no-color option #3

Open rinderschwein opened 11 years ago

rinderschwein commented 11 years ago

The plugin does not work with team city build chain and not with scala build tool without this patch, because there is no interactive shell.

ben-eb commented 10 years ago

I've also run into problems when running this task under spawn and capturing the output. For me, a better patch would be to check for process.stdout.clearLine and process.stdout.cursorTo methods when running the update function. Like this patch does. Perhaps something like this?

        var update = function()
        {
            // only call these if the env we're in
            // supports those methods
            if (process.stdout.clearLine && process.stdout.cursorTo) {
                if (!total) {
                    return;
                }

                process.stdout.clearLine();
                process.stdout.cursorTo(0);

                var str = style('0%', 'yellow') + ' [ ',
                    arr = [],
                    count = total,
                    percent = ((100 / total) * completed).toFixed(2);

                while(count--) {
                    arr.push(count < completed ? '=' : ' ');
                }
                str += arr.reverse().join('');
                str += ' ] ' + style(percent + "%", 'green') + ' (' + ((new Date() - start) / 1000).toFixed(1) + 's) ';
                process.stdout.write(str);
            }
        };

grunt --no-color, in my opinion, should preserve all functionality that the task had before, just removing the ANSI code from the output.

jkleijn commented 10 years ago

Ah, I did something similar to get the task to work with Jenkins.