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

'safe' colors not showing up when using foreman #121

Closed
fiznool opened this issue Apr 18, 2015 · 5 comments
Closed

'safe' colors not showing up when using foreman #121

fiznool opened this issue Apr 18, 2015 · 5 comments

Comments

@fiznool
Copy link

fiznool commented Apr 18, 2015

When running the node app with foreman, strings colored with colors/safe do not display. This is an issue since Heroku uses foreman to run node apps, and so logs will not show up in color.

Using the following Procfile:

web: node index.js

The following code produces colorized output:

require('colors');
console.log('this should be red'.red);

screenshot from 2015-04-18 10 15 54

but the following does not:

var colors = require('colors/safe');
console.log(colors.red('this should be red'));

screenshot from 2015-04-18 10 16 34

@fiznool
Copy link
Author

fiznool commented Apr 18, 2015

For reference, this is also an issue when using grunt-express-server.

// Gruntfile.js
module.exports = function(grunt) {
  grunt.loadNpmTasks('grunt-express-server');
  grunt.initConfig({
    express: {
      dev: {
        options: {
          script: 'index.js'
        }
      }
    }
  });
};

screenshot from 2015-04-18 10 32 52

@Chocobozzz
Copy link

Same here with grunt-express-server. It's quite annoying since we can't have a colorized output with Winston using Grunt for example.

@iDVB
Copy link

iDVB commented Sep 14, 2015

+1 (grunt-express-server, wilson)

@fiznool
Copy link
Author

fiznool commented Nov 9, 2015

So it looks like the problem is for non-TTY environments, colors.enabled is always set to false.

But we can easily force the colors to be enabled simply by setting:

var colors = require('colors');
colors.enabled = true;

@DABH
Copy link
Contributor

DABH commented Feb 17, 2018

Yep, you can force colors to true (check out lib/system/supports-colors.js for additional command line args etc. you can pass to force colors to be enabled). Please feel free to re-open if this issue persists with colors@next. Thanks!

@DABH DABH closed this as completed Feb 17, 2018
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

4 participants